Code:-
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
try{
imageUr
With the guidance of CommonsWare Sir, I resolved my problem by doing the following changes...
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
destination = Environment.getExternalStorageDirectory().getPath() + "/image.jpg";
outputUri= Uri.fromFile(new File(destination));
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
} else {
List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
grantUriPermission(packageName, outputUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
}
startActivityForResult(intent, REQUEST_CAMERA);