2013-03-27 27 views
2

我已在目前以下:在代碼中打開Android Gallery的強大方式是什麼?

Intent intent = new Intent(Intent.ACTION_VIEW, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI); 
startActivity(intent); 

它完全在大多數情況下,但它至少是一個Android 2.3.4設備產生以下異常:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://media/external/video/media } 

任何人都可以共享通用在Android設備上打開Gallery的方法?

回答

1

如果你談論的是打開圖片庫,下面可以用來從SD卡中選擇圖像:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
intent.setType("image/*"); 
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);//only local images 
startActivityForResult(intent, IMAGE_PICK_ADD); 
+0

感謝您的及時回覆。我應該說我是指視頻文件。我更改了代碼以使用intent.setType(「video/*」);它確實顯示了所有的視頻文件,但我更喜歡使用顯示所有文件夾的圖庫,而不僅僅是文件列表。 – Hong 2013-03-27 20:13:09

相關問題