My app has the option of passing a ACTION_CAPTURE_IMAGE
Intent to the Camera App post which I provide an option to crop the image with any available App that can crop it. Now, since Google Photos is being made available by default on many of the devices these days, it turns out that often Google Photos is the only App available for crop.
Now, there is no problem capturing or cropping images on API level <= 23 but with the API level 24, the security model of Android has made changes and now the we are not allowed to expose a file://
URI directly through an Intent. This has been discussed on SO too:
The solution uses a ContentProvider
and the solution works except now we talk in terms of content://
instead of file://
So, I am now sending a content://
URI to any available cropping App. Turns out, Google Photos is showing the Toast - "Editing not supported on this image". This is because of the inability of handling a content://
URI. Now, if some third party App doesn't handle a content://
URI and Android doesn't let me pass a file://
URI, how am I supposed to have the image cropped?
The code that sends the CROP request for reference:
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");
List < ResolveInfo > list = getPackageManager().queryIntentActivities(
intent, 0);
int size = list.size();
if (size == 0) {
Toast.makeText(this, "Can not find image crop app",
Toast.LENGTH_SHORT).show();
} else {
//intent.setData(mImageCaptureUri);
intent.setDataAndType(mImageCaptureUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("outputX", 150);
intent.putExtra("outputY", 150);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (size == 1) {
Intent i = new Intent(intent);
ResolveInfo res = list.get(0);
i.setComponent(new ComponentName(res.activityInfo.packageName,
res.activityInfo.name));
startActivityForResult(i, CROP_FROM_CAMERA);
}
And here is the Logcat output:
09-01 15:57:19.588 2347-4568/system_process I/ActivityManager: Start proc 7045:com.google.android.apps.photos/u0a64 for activity com.google.android.apps.photos/.photoeditor.intents.EditActivity
09-01 15:57:19.630 6179-6260/com.snap.testsnapboard D/EGL_emulation: eglMakeCurrent: 0xa9005de0: ver 2 0 (tinfo 0xa9003780)
09-01 15:57:19.834 7045-7045/com.google.android.apps.photos W/System: ClassLoader referenced unknown path: /system/app/Photos/lib/x86
09-01 15:57:20.521 7045-7045/com.google.android.apps.photos W/TrustedPartners: no provider found for com.motorola.camera.provider.bestshotprovider.BestShotProvider; do not trust
09-01 15:57:20.522 7045-7045/com.google.android.apps.photos W/TrustedPartners: no provider found for com.google.android.apps.photos.api.SpecialTypesProvider; do not trust
09-01 15:57:20.522 7045-7045/com.google.android.apps.photos W/TrustedPartners: no provider found for com.lge.photos.specialtypeprovider; do not trust