2013-03-27 80 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

相关问题