仅从Android库中挑选图片

时间:2017-03-15 10:10:28

标签: android android-intent android-gallery

我用

 Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent, null), Photo.REQUEST_PICK_FROM_EXISTING);

仅显示图像,并且可以选择使用显示视频的第三方文件管理器应用。我希望用户选择第三方应用,但只选择图片。有没有办法控制它?

1 个答案:

答案 0 :(得分:0)

使用以下代码:

     Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
     photoPickerIntent.setType("image/*");
     startActivityForResult(photoPickerIntent, SELECT_PHOTO);

希望这有帮助。