Selasa, 30 Juni 2020

Set Notif Android Studio






package com.example.layanancomplain;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Toast;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class Menu_engineer extends AppCompatActivity {
    String ip="",PESAN="",id_penugasan;
    Handler mHandler;
    JSONParser jsonParser = new JSONParser();
    Vibrator vibrator;
    CardView btnProfil, btnPenugasan, btnArsip, btnExit;

    String id_user, nama_user;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu_engineer);
        ip=jsonParser.getIP();
        vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

        SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(Menu_engineer.this);
        Boolean Registered = sharedPref.getBoolean("Registered", false);
        if (!Registered){
            finish();
        }else {
            id_user= sharedPref.getString("id_user", "");
            nama_user = sharedPref.getString("nama_user", "");
        }

        btnProfil=(CardView)findViewById(R.id.btnProfil);
        btnProfil.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                Intent i = new Intent(Menu_engineer.this,Profil_user.class);
                i.putExtra("pk", id_user);
                startActivity(i);
            }});

        btnPenugasan=(CardView)findViewById(R.id.btnPenugasan);
        btnPenugasan.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                Intent i = new Intent(Menu_engineer.this,List_penugasan.class);
                startActivity(i);
            }});

        btnArsip=(CardView)findViewById(R.id.btnArsip);
        btnArsip.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                Intent i = new Intent(Menu_engineer.this,List_arsip_penugasan.class);
                startActivity(i);
            }});

        btnExit=(CardView)findViewById(R.id.btnExit);
        btnExit.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
               keluarYN();
            }});

        this.mHandler = new Handler();
        m_Runnable.run();
    }

    private final Runnable m_Runnable = new Runnable()    {
        public void run()  {
            new Menu_engineer.load().execute();
            Menu_engineer.this.mHandler.postDelayed(m_Runnable,5000);
        }
    };
    private void addNotification1() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            vibrator.vibrate(VibrationEffect.createOneShot(1000, VibrationEffect.DEFAULT_AMPLITUDE));
        }

        Toast.makeText(Menu_engineer.this,"Info "+PESAN,Toast.LENGTH_SHORT).show();
        NotificationCompat.Builder builder =
                new NotificationCompat.Builder(this)
                        .setSmallIcon(R.drawable.phone_icon)
                        .setContentTitle("Konfirmasi Teknisi Untuk Penugasan ")
                        .setContentText(PESAN);

        Intent notificationIntent = new Intent(this, NorifCustomer.class);//eventList        notificationIntent.putExtra("id_penugasan", id_penugasan);
        notificationIntent.putExtra("PESAN", PESAN);

        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
        builder.setContentIntent(contentIntent);
        NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        manager.notify(0, builder.build());

    }
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            keluarYN();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    public void keluar(){
        new AlertDialog.Builder(this)
                .setTitle("Menutup Aplikasi")
                .setMessage("Terimakasih... Anda Telah Menggunakan Aplikasi Ini")
                .setNeutralButton("Tutup", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sumthin) {
                        finish();
                    }})
                .show();
    }


    public void keluarYN(){
        AlertDialog.Builder ad=new AlertDialog.Builder(Menu_engineer.this);
        ad.setTitle("Konfirmasi");
        ad.setMessage("Apakah benar ingin keluar?");

        ad.setPositiveButton("OK",new DialogInterface.OnClickListener(){
            @Override            public void onClick(DialogInterface dialog, int which) {
                keluar();
            }});

        ad.setNegativeButton("No",new DialogInterface.OnClickListener(){
            public void onClick(DialogInterface arg0, int arg1) {
            }});

        ad.show();
    }


    int adabaru=0;
    class load extends AsyncTask<String, String, String> {
        @Override        protected void onPreExecute() {
            super.onPreExecute();
        }
        protected String doInBackground(String... args) {
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("id_user", id_user));
            JSONObject json = jsonParser.makeHttpRequest(ip+"penugasanteknisi.php", "GET", params);
            Log.d("show: ", json.toString());
            try {
                adabaru= json.getInt("sukses");
                if(adabaru==1){
                    PESAN= json.getString("PESAN");
                    id_penugasan= json.getString("id_penugasan");
                }
            }
            catch (JSONException e) {e.printStackTrace();}
            return null;
        }

        protected void onPostExecute(String file_url) {
            runOnUiThread(new Runnable() {
                public void run() {
                    if (adabaru==1){
                        adabaru=0;
                        addNotification1();
                        Toast.makeText(Menu_engineer.this,"Ada Info dari Petugas...="+PESAN,Toast.LENGTH_SHORT).show();
                    }
                }
            });}
    }

}


<?php 
require_once"konmysqli.php";
$respon = array();

if (isset($_GET["id_user"])) {
    $id_user = $_GET['id_user'];
 $sql="SELECT * FROM `$tbpenugasan` WHERE `$tbpenugasan`.`id_user` = 
 '$id_user' and  `$tbpenugasan`.`notif_teknisi`='0'";
    
 $jum=getJum($conn,$sql);
    if ($jum>0) {
            $d=getField($conn,$sql);
      $record = array();
            $id_penugasan = $d["id_penugasan"];
   $pesanketeknisi= $d["pesan"];
   $id_user = $d["id_user"];
   $status = $d["status"];
   $id_complain= $d["id_complain"];
   
   $namateknisi=getUserM($conn,$id_user);
   $pesan= $d["pesan"];
   
   $respon["pesankecustomer"]="Status $status |Penugasan ke Teknisi $namateknisi ($id_user)";
   
   $respon["PESAN"]="$pesan (NO Complain $id_complain)";
   
   $respon["id_penugasan"]=$id_penugasan;
   $respon["pesan"] =$pesan;
   
   
            $respon["sukses"] = 1;
   
   $sqlm="update `$tbpenugasan` set `notif_teknisi`='1' WHERE `id_penugasan` = '$id_penugasan'";
   //processM($conn,$sqlm);
   
   
             $respon["pesan"] = "$jum record";
   echo json_encode($respon);
        } else {
            $respon["sukses"] = 0;
            $respon["pesan"] = "0 record";
            echo json_encode($respon);
        }

} else {
    $respon["sukses"] = 0;
    $respon["pesan"] = "? lengkapi data";
    echo json_encode($respon);
}
?>

<?php

function getJum($conn,$sql){
  $rs=$conn->query($sql);
  $jum= $rs->num_rows;
 $rs->free();
 return $jum;
}

function getField($conn,$sql){
 $rs=$conn->query($sql);
 $rs->data_seek(0);
 $d= $rs->fetch_assoc();
 $rs->free();
 return $d;
}
?>

Upload And Load Image



package com.example.layanancomplain;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;

import android.Manifest;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ContentValues;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;


public class UploadToServer extends AppCompatActivity {
    String myip="", myFILE="",id_penugasan="";
    JSONParser jsonParser = new JSONParser();



    private static final int PICK_IMAGE = 1;
    private static final int PICK_Camera_IMAGE = 2;
    private ImageView imgView;
    private Button upload,cancel;
    private Bitmap bitmap;
    Uri imageUri;
    MediaPlayer mp=new MediaPlayer();

    String URL="",NFUpload="";
    TextView messageText;
    Button uploadButton,btnpilih,btncamera;
    int serverResponseCode = 0;
    ProgressDialog dialog = null;

    String upLoadServerUri = null;

    /**********  File Path *************/    final String uploadFilePath = "/mnt/sdcard/";
    String uploadFileName = "myfile.jpg";


    private static final int MY_PERMISSION_REQUEST = 1;

    @Override    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.uploadserver);


        if (ContextCompat.checkSelfPermission(UploadToServer.this,
                Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(UploadToServer.this,
                    Manifest.permission.CAMERA)) {
                ActivityCompat.requestPermissions(UploadToServer.this,
                        new String[]{Manifest.permission.CAMERA}, MY_PERMISSION_REQUEST);
            } else {
                ActivityCompat.requestPermissions(UploadToServer.this,
                        new String[]{Manifest.permission.CAMERA}, MY_PERMISSION_REQUEST);
            }
        } else {
            //DO NOTHING        }



        Intent i = getIntent();
        id_penugasan = i.getStringExtra("pk");


        imgView = (ImageView) findViewById(R.id.imageView);
        uploadButton = (Button)findViewById(R.id.uploadButton);
        messageText  = (TextView)findViewById(R.id.messageText);

        btnpilih = (Button)findViewById(R.id.btnpilih);
        btncamera = (Button)findViewById(R.id.btncamera);

        messageText.setText(uploadFilePath+"/"+uploadFileName+"'");

        /************* Php script path ****************/        URL=jsonParser.getIP()+"uploadserver.php";
        upLoadServerUri =   URL;
        uploadButton.setOnClickListener(new OnClickListener() {
            @Override            public void onClick(View v) {

                dialog = ProgressDialog.show(UploadToServer.this, "", "Uploading file...", true);

                new Thread(new Runnable() {
                    public void run() {
                        runOnUiThread(new Runnable() {
                            public void run() {
                               messageText.setText("uploading started.....");
                            }
                        });
                        String AL=messageText.getText().toString();
                        File f=new File(AL);
                        myFILE=f.getName();
                        uploadFiles(AL);

                       
                    }
                }).start();
                
                
              
            }
        });


        btnpilih.setOnClickListener(new OnClickListener() {
            @Override            public void onClick(View v) {
                try {
                    Intent gintent = new Intent();
                    gintent.setType("image/*");
                    gintent.setAction(Intent.ACTION_GET_CONTENT);
                    startActivityForResult(Intent.createChooser(gintent, "Select Picture"),PICK_IMAGE);
                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(),
                            e.getMessage(),
                            Toast.LENGTH_LONG).show();
                    Log.e(e.getClass().getName(), e.getMessage(), e);
                }
            }
        });


        btncamera.setOnClickListener(new OnClickListener() {
            @Override            public void onClick(View v) {
                //define the file-name to save photo taken by Camera activity                String fileName = "new-photo-name.jpg";
                //create parameters for Intent with filename                ContentValues values = new ContentValues();
                values.put(MediaStore.Images.Media.TITLE, fileName);
                values.put(MediaStore.Images.Media.DESCRIPTION,"Image captured by camera");
                //imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState)                imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
                //create new Intent                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
                startActivityForResult(intent, PICK_Camera_IMAGE);
            }
        });
    }

    public int uploadFiles(String sourceFileUri) {
        String fileName = sourceFileUri;
        NFUpload=fileName;
        uploadFileName=NFUpload;
        HttpURLConnection conn = null;
        DataOutputStream dos = null;
        String lineEnd = "\r\n";
        String twoHyphens = "--";
        String boundary = "*****";
        int bytesRead, bytesAvailable, bufferSize;
        byte[] buffer;
        int maxBufferSize = 1 * 1024 * 1024;
        File sourceFile = new File(sourceFileUri);

        if (!sourceFile.isFile()) {

            dialog.dismiss();
            
            Log.d("uploadFile", "Source File not exist :"                    +uploadFilePath + "" + uploadFileName);

            runOnUiThread(new Runnable() {
                public void run() {
                    messageText.setText("Source File not exist :"                            +uploadFilePath + "" + uploadFileName);
                }
            });

            return 0;

        }
        else        {
            try {

                // open a URL connection to the Servlet                FileInputStream fileInputStream = new FileInputStream(sourceFile);
                URL url = new URL(upLoadServerUri);

                // Open a HTTP  connection to  the URL                conn = (HttpURLConnection) url.openConnection();
                conn.setDoInput(true); // Allow Inputs                conn.setDoOutput(true); // Allow Outputs                conn.setUseCaches(false); // Don't use a Cached Copy                conn.setRequestMethod("POST");
                conn.setRequestProperty("Connection", "Keep-Alive");
                conn.setRequestProperty("ENCTYPE", "multipart/form-data");
                conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
                conn.setRequestProperty("uploaded_file", fileName);
              
                dos = new DataOutputStream(conn.getOutputStream());

                dos.writeBytes(twoHyphens + boundary + lineEnd);
                dos.writeBytes("Content-Disposition: form-data; name=\"uploaded_file\";filename=\""                        + fileName + "\"" + lineEnd);

                dos.writeBytes(lineEnd);

                // create a buffer of  maximum size                bytesAvailable = fileInputStream.available();

                bufferSize = Math.min(bytesAvailable, maxBufferSize);
                buffer = new byte[bufferSize];

                // read file and write it into form...                bytesRead = fileInputStream.read(buffer, 0, bufferSize);

                while (bytesRead > 0) {

                    dos.write(buffer, 0, bufferSize);
                    bytesAvailable = fileInputStream.available();
                    bufferSize = Math.min(bytesAvailable, maxBufferSize);
                    bytesRead = fileInputStream.read(buffer, 0, bufferSize);

                }

                // send multipart form data necesssary after file data...                dos.writeBytes(lineEnd);
                dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);

                // Responses from the server (code and message)                serverResponseCode = conn.getResponseCode();
                String serverResponseMessage = conn.getResponseMessage();

                Log.i("uploadFile", "HTTP Response is : "                        + serverResponseMessage + ": " + serverResponseCode);

                if(serverResponseCode == 200){

                    runOnUiThread(new Runnable() {
                        public void run() {

                            String msg = "File Upload Completed:" + uploadFileName;

                            messageText.setText(msg);
                            Toast.makeText(UploadToServer.this, "File Upload Complete.",
                                    Toast.LENGTH_SHORT).show();
                        }
                    });
                }

                //close the streams //                fileInputStream.close();
                dos.flush();
                dos.close();

                
                Intent i = new Intent(UploadToServer.this,Add_complain.class);
                i.putExtra("upload", myFILE);
                   startActivity(i); 
                   finish();
                   
                   
            } catch (MalformedURLException ex) {

                dialog.dismiss();
                ex.printStackTrace();

                runOnUiThread(new Runnable() {
                    public void run() {
                        messageText.setText("MalformedURLException Exception : check script url.");
                        Toast.makeText(UploadToServer.this, "MalformedURLException", Toast.LENGTH_SHORT).show();
                    }
                });

                Log.e("Upload file to server", "error: " + ex.getMessage(), ex);
            } catch (Exception e) {

                dialog.dismiss();
                e.printStackTrace();

                runOnUiThread(new Runnable() {
                    public void run() {
                        messageText.setText("Got Exception : see logcat ");
                        Toast.makeText(UploadToServer.this, "Got Exception : see logcat ",
                                Toast.LENGTH_SHORT).show();
                    }
                });

            }
            dialog.dismiss();
            return serverResponseCode;

        } // End else block    }





    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        Uri selectedImageUri = null;
        String filePath = null;
        switch (requestCode) {
            case PICK_IMAGE:
                if (resultCode == Activity.RESULT_OK) {
                    selectedImageUri = data.getData();
                }
                break;
            case PICK_Camera_IMAGE:
                if (resultCode == RESULT_OK) {
                    //use imageUri here to access the image                    selectedImageUri = imageUri;
          /*Bitmap mPic = (Bitmap) data.getExtras().get("data");      selectedImageUri = Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), mPic, getResources().getString(R.string.app_name), Long.toString(System.currentTimeMillis())));*/                } else if (resultCode == RESULT_CANCELED) {
                    Toast.makeText(this, "Picture was not taken", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(this, "Picture was not taken", Toast.LENGTH_SHORT).show();
                }
                break;
        }

        if(selectedImageUri != null){
            try {
                // OI FILE Manager                String filemanagerstring = selectedImageUri.getPath();

                // MEDIA GALLERY                String selectedImagePath = getPath(selectedImageUri);

                   
                messageText.setText(selectedImagePath);


                if (selectedImagePath != null) {
                    filePath = selectedImagePath;
                } else if (filemanagerstring != null) {
                    filePath = filemanagerstring;
                } else {
                    Toast.makeText(getApplicationContext(), "Unknown path",
                            Toast.LENGTH_LONG).show();
                    Log.e("Bitmap", "Unknown path");
                }

                if (filePath != null) {
                    decodeFile(filePath);
                } else {
                    bitmap = null;
                }
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(), "Internal error",
                        Toast.LENGTH_LONG).show();
                Log.e(e.getClass().getName(), e.getMessage(), e);
            }
        }

    }



    class ImageGalleryTask extends AsyncTask<Void, Void, String> {
        @SuppressWarnings("unused")
        @Override        protected String doInBackground(Void... unsued) {
            InputStream is;
            BitmapFactory.Options bfo;
            Bitmap bitmapOrg;
            ByteArrayOutputStream bao ;

            bfo = new BitmapFactory.Options();
            bfo.inSampleSize = 2;
            //bitmapOrg = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + customImage, bfo);
            bao = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bao);
            byte [] ba = bao.toByteArray();
//            String ba1 = Base64.encodeBytes(ba);
            String ba1 = Base64.encodeToString(ba,1);
            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("image",ba1));
            nameValuePairs.add(new BasicNameValuePair("cmd","image_android"));
            Log.v("log_tag", System.currentTimeMillis()+".jpg");
            try{
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new                        //  Here you need to put your server file address

                        HttpPost(URL);//"http://www.picsily.com/upload_photo.php");                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();
                Log.v("log_tag", "In the try Loop" );
            }catch(Exception e){
                Log.v("log_tag", "Error in http connection "+e.toString());
            }
            return "Success";
            // (null);        }

        @Override        protected void onProgressUpdate(Void... unsued) {

        }

        @Override        protected void onPostExecute(String sResponse) {
            try {
                if (dialog.isShowing())
                    dialog.dismiss();
            } catch (Exception e) {
                Toast.makeText(getApplicationContext(),
                        e.getMessage(),
                        Toast.LENGTH_LONG).show();
                Log.e(e.getClass().getName(), e.getMessage(), e);
            }
        }

    }

    public String getPath(Uri uri) {
        String[] projection = { MediaStore.Images.Media.DATA };
        Cursor cursor = managedQuery(uri, projection, null, null, null);
        if (cursor != null) {
            // HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL            // THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA            int column_index = cursor
                    .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToFirst();
            return cursor.getString(column_index);
        } else            return null;
    }

    public void decodeFile(String filePath) {
        // Decode image size        BitmapFactory.Options o = new BitmapFactory.Options();
        o.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, o);

        // The new size we want to scale to        final int REQUIRED_SIZE = 1024;

        // Find the correct scale value. It should be the power of 2.        int width_tmp = o.outWidth, height_tmp = o.outHeight;
        int scale = 1;
        while (true) {
            if (width_tmp < REQUIRED_SIZE && height_tmp < REQUIRED_SIZE)
                break;
            width_tmp /= 2;
            height_tmp /= 2;
            scale *= 2;
        }

        // Decode with inSampleSize        BitmapFactory.Options o2 = new BitmapFactory.Options();
        o2.inSampleSize = scale;
        bitmap = BitmapFactory.decodeFile(filePath, o2);

        imgView.setImageBitmap(bitmap);

    }

}




<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    >

    <ImageView        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:layout_weight="1"        android:id="@+id/imageView" />


    <Button        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="Choose File"        android:id="@+id/btnpilih"        />


    <Button        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="Camera"        android:id="@+id/btncamera"        />

    <Button        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="Click To Upload File"        android:id="@+id/uploadButton"        />

    <TextView        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text=""        android:id="@+id/messageText"        android:textColor="#000000"        android:textStyle="bold"        />
</LinearLayout>


<?php
  require_once"konmysqli.php";
    $file_path = "ypathfile/";
   
 $IMG=$_FILES['uploaded_file']['name'];
    $file_path = $file_path . basename( $IMG);
    if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $file_path)) {
        echo "success";
     
    } else{
        echo "fail";
    }
 ?>