2012-02-17 47 views
1

如何用画廊等其他应用程序打开图片?Android intent image

那么我有什么打算?

Intent in=new Intent("intent?"); 
     startActivity(in); 
+0

的[在Android的内置图库应用程序打开一个图像编程]可能重复(http://stackoverflow.com/questions/2169649 /开放式的图像功能于机器人-内置画廊-APP-编程) – MByD 2012-02-17 13:01:36

+0

退房[此] [1] [1]:http://stackoverflow.com/questions/ 2169649/open-an-image-in-androids-built-in-gallery-app-programmatically – 2012-02-17 13:36:11

+0

Chekc out [this] [1] [1]:http://stackoverflow.com/questions/2169649/open-an-image-in-androids-built-in-gallery-app-programmatically – 2012-02-17 13:37:27

回答

2

这将创建Android的意图,以显示图像/ PNG。

Intent intent = new Intent(); 
intent.setAction(android.content.Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.fromFile(new File(path)), "image/png"); 
startActivity(intent); 

只要确保该文件位于所有人都可见的位置,而不是在您的私人沙箱中。将其保存到数据文件夹中的SD卡是常见的,例如。 /sdcard/data/appname/filename.png

0

使用本

 intent.setData(android.Provider.MediaStore.Images.Media.Data);