我使用以下代码来挑选图片。
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
photoPickerIntent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(Intent.createChooser(photoPickerIntent, getActivity().getResources().getString(R.string.select_picture)), 1);
它的工作正常,但它只允许我从默认的照片应用程序中选择图像。我想从" Gallery"中选择图像。甚至在今天的最新设备中应用。即使对于 Lollipop ,我也不知道 WhatsApp 是如何做到这一点的。
答案 0 :(得分:1)
我在我的应用程序中使用此代码,它对我来说很好..
intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/* video/*");
startActivityForResult(intent, 3);