Skip to content Skip to sidebar Skip to footer

Android : Uri For Open An Image With Action View

This is the code protected static final String DIR_IMAGE = '/data/data/it.android.myprogram/images/'; Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION

Solution 1:

Files in /data/data/it.android.myprogram are only accessible by your application. If you want to send them via Intent to others applications, you must copy content in using openFileOutput method of your activity.

protectedstaticfinalStringDIR_IMAGE="/data/data/it.android.myprogram/images/";
StringfilePath= DIR_IMAGE + "fileName";
FileInputStreamfileInputStream=newFileInputStream(newFile(filePath));
FileOutputStreamfileOutputStream= openFileOutput("fileName", Activity.MODE_WORLD_READABLE);
ByteStreams.copy(fileInputStream, fileOutputStream);
Intentintent=newIntent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("content://it.android.myprogram/fileName"), "image/*");

Hope it helps

Post a Comment for "Android : Uri For Open An Image With Action View"