I'm developing an app that allows users to take photos, draw on them, and then upload them into our social media application. I would like to use a third-party app for the drawing to lessen the work load on us. I found a number of answers on here about how to do so, and much of the following code is taken from those answers. When I try different combinations of answers, I always get Toast errors on the Intent. The two errors I get are "File could not be opened" and "Image could not be edited". The former sounds like file permissions problems, which I think should be getting resolved from the grantUriPermissions work-around below. The other error I have no idea about.
// Code taken from answer on http://stackoverflow.com/questions/15699299/android-edit-image-intent
final Uri uri = Uri.parse(this.photoPath);
int flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION;
Intent editIntent = new Intent(Intent.ACTION_EDIT);
editIntent.setDataAndType(uri, "image/*");
editIntent.addFlags(flags);
editIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
// This work-around allows the intent to access our private FileProvider storage.
// Code taken from http://stackoverflow.com/questions/24835364/android-open-private-file-with-third-party-app
List<ResolveInfo> resInfoList = this.getPackageManager().queryIntentActivities(editIntent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
this.grantUriPermission(packageName, uri, flags);
}
startActivityForResult(Intent.createChooser(editIntent, null), EDIT_INTENT);
Anybody seen these Toast messages before and been able to resolve them?