android - Gallery can't display image from internal storage -
i have image stored in internal storage of app. can grab path , can succesfully set image view. when trying let user open using gallery (intent), displays black screen.
myintent.setdataandtype(uri.fromfile(file), mimetype); intent = intent.createchooser(myintent, "choose viewer"); startactivity(intent);
i pretty sure has permission gallery cant access private storage of app reason. there way "beside moving file external storage"
thanks
use fileprovider
serve file internal storage. quoting documentation:
fileprovider special subclass of contentprovider facilitates secure sharing of files associated app creating content:// uri file instead of file:/// uri.
a content uri allows grant read , write access using temporary access permissions. when create intent containing content uri, in order send content uri client app, can call intent.setflags() add permissions. these permissions available client app long stack receiving activity active.
Comments
Post a Comment