Camera intent opens camera but does not show tick and cross page when click image

934 views Asked by At

I used similar code in different apps but still this time I am getting a problem. upon calling startActivityForResult(CamIntent, Integer.parseInt(code)); camera open but when I click image nothing happens it keeps clicking the image but does not show image page with tick and cross icons.

In Manifest File

<provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"></meta-data>
        </provider>

@xml/file_paths

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="." />
</paths>

Code in Activity

public void ClickImageFromCamera(String code) {


        Intent CamIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);




        File destination = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis() + ".jpg");
        Log.e("img fromCam", String.valueOf(destination));

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            uri = FileProvider.getUriForFile(Objects.requireNonNull(getApplicationContext()),
                    BuildConfig.APPLICATION_ID + ".fileprovider", destination);
           Log.e("img uri", String.valueOf(uri));

            CamIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        } else {
            uri = Uri.fromFile(destination);
            CamIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        }
        CamIntent.putExtra("return-data", true);
        startActivityForResult(CamIntent, Integer.parseInt(code));






    }

Log

D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10625; state: DISABLED
D/OpenGLRenderer: endAllActiveAnimators on 0x76e3d22fc0 (AlertController$RecycleListView) with handle 0x7603cc4890
E/img fromCam: /storage/emulated/0/1611230389449.jpg
E/img uri: content://com.example.aps.fileprovider/external_files/1611230389449.jpg

E/Request code: 0 (when I click back)
E/ResultCode: 0

1

There are 1 answers

2
Sandeep Kumar On

    private void openCameraImagePickerIntent() {
        int FRONT_CAMERA = 0;
        int BACK_CAMERA = 1;
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra("android.intent.extras.CAMERA_FACING",BACK_CAMERA);
        startActivityForResult(intent, 14596);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 14596 && resultCode == RESULT_OK) {
            Bitmap imageBitmap = (Bitmap) data.getExtras().get("data");
            //Save imageBitmap in storage
        }
    }