2012-02-17 48 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);