android implicit intent edit failed to load image -
this implicit intent invoke image editing apps on device:
startactivity(new intent(intent.action_edit).setdataandtype(myuri, getmimetype(myuri)).setflags(intent.flag_grant_read_uri_permission | intent.flag_grant_write_uri_permission)); and how getmimetype:
public string getmimetype(uri uri) { string mimetype = null; if (uri.getscheme().equals(contentresolver.scheme_content)) { contentresolver cr = getcontentresolver(); mimetype = cr.gettype(uri); } else { string fileextension = mimetypemap.getfileextensionfromurl(uri .tostring()); mimetype = mimetypemap.getsingleton().getmimetypefromextension( fileextension.tolowercase()); } return mimetype; } for apps crashes load:
on app sketch_camera invisible page loads , disables interaction app.
on app airbrush loads app crashes message "failed load image".
is related minimum sdk version mine 16? i've tested on minimum sdk version of 9 , no change in result.
is there else should add intent work apps?
i've tried putextra , doesn't help:
.putextra(intent.action_edit, myuri); i've gallery apps on device , of them launch sketch_camera , airbrush without problem.
what's happening here? i'm confused after 2 days of struggling phenomena.
it's file created path of 1 media store file querying mediastore.images.media.external_content_uri
there no guarantee other app has rights location, or your app has rights location. example, image on removable storage. besides, the file uri scheme being banned cross-app usage, anyway.
use content uri instead. example, in this sample app, query mediastore videos. given cursor named row positioned @ particular video, generate uri via:
videouri= contenturis.withappendedid( mediastore.video.media.external_content_uri, row.getint(row.getcolumnindex(mediastore.video.media._id))); this uri both works own purposes (e.g., hand picasso thumbnail, hand videoview playback) , handing third-party apps (e.g., action_view playback).
other changing base uri 1 queried against (mediastore.images.media.external_content_uri), same basic code should work you.
also, rid of flags intent. intent points own contentprovider, not case in either original code or uri create withappendedid().
Comments
Post a Comment