【发布时间】:2018-08-10 06:14:51
【问题描述】:
我是 android 新手,我编写了代码来从图库中选择多个图像,为了实现这一点,我编写了 2 种方法。
在onActivityResult 上,我使用data.getClipdata 到recieve 每个图像。
这是选择多张图片的第一种方式。
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), RESULT_LOAD_IMAGE);
这是选择多张图片的第二种方式。
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(intent,RESULT_LOAD_IMAGE);
我选择了第二种选择多张图片的方式,因为在实现这一点时,它看起来更适合我的应用程序,我可以在单击时选择多张图片并停止使用第一种方式,因为我必须使用长按选择多张图片。事情进展顺利,就像在 android studio 模拟器和诺基亚设备 USB 调试上一样。但在一台三星设备上,我根本无法选择图像,而第一种方法在这里奏效。所以我的问题是如果可能的话,如何在这种情况下使用第二种方式来实现多个图像,并且这个问题也会出现在其他设备上吗?
【问题讨论】:
-
我建议最好使用库Matisse
-
是的图书馆好多了
标签: android image android-intent android-gallery