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