android - How to open a picture in gallery -


i want open picture in gallery. gallery path root + "/saved_images" , name fname. opens gallery can choose picture, want open directly picture.

string root = environment.getexternalstoragepublicdirectory(environment.directory_pictures).tostring(); string fname = "image-" + formatteddate + ".jpg";  intent intent = new intent(); intent.setaction(intent.action_view); intent.setdataandtype(uri.parse(root + "/saved_images"+fname), "image/*"); startactivity(intent); 

environment.getexternalstoragepublicdirectory(environment.directory_pictures).tostring() returns in form of "/storage/emulated/0/pictures".

to have valid uri, misses "file://" in front of file path.

additionally, if "saved_images" directory, missing / between directory name , filename.

all together,

intent.setdataandtype(uri.parse("file://" + root + "/saved_images/" + fname), "image/*"); 

should job.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -