I want to open multiple images from the Android gallery using "Intent.EXTRA_ALLOW_MULTIPLE" intent filter:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(Intent.createChooser(intent, "Add images"), SELECT_MULTIPLE_IMAGES);
But whatever app I use (native gallery, QuickPic app), I can only select one single picture. The test device is running Android 5.1.
How can I pick multiple images?
This is currently working in one of my recent live application which covers selection of images using Gallary for 4.4 and above and below that using writing your own custom gallery.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
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"), SELECT_IMAGE_REQUEST_GALLERY);
}catch(Exception e){
Intent photoPickerIntent = new Intent(this, XYZ.class);
startActivityForResult(photoPickerIntent, SELECT_IMAGE_REQUEST);
} else {
Intent photoPickerIntent = new Intent(this, XYZ.class);
startActivityForResult(photoPickerIntent, SELECT_IMAGE_REQUEST);
Ther is no multi select in the native gallery, but you can do it with this library :
https://github.com/luminousman/MultipleImagePick
* Extra used to indicate that an intent can allow the user to select and
* return multiple items. This is a boolean extra; the default is false. If
* true, an implementation is allowed to present the user with a UI where
* they can pick multiple items that are all returned to the caller. When
* this happens, they should be returned as the {@link #getClipData()} part
* of the result Intent.
* @see #ACTION_GET_CONTENT
* @see #ACTION_OPEN_DOCUMENT
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
if (data.getData() != null) {
try {
files.clear();
Uri uri = data.getData();
String url = FileUtils2.getPath(this, uri);
assert url != null;
File file = new File(url);
files.add(file);
mPresenter.postAnnexData(files);
} catch (Exception e) {
e.printStackTrace();
} else {
//If uploaded with the new Android Photos gallery
ClipData clipData = data.getClipData();
files.clear();
if (clipData != null) {
for (int i = 0; i < clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
Uri uri = item.getUri();
String url = FileUtils2.getPath(this, uri);
assert url != null;
File file = new File(url);
files.add(file);
mPresenter.postAnnexData(files);
来源:https://stackoverflow.com/questions/31002388/android-intent-extra-allow-multiple-allows-only-single-picking
android intent multi_pick 自定在哪里,Android: Intent.EXTRA_ALLOW_MULTIPLE allows only single picking...
问题I want to open multiple images from the Android gallery using "Intent.EXTRA_ALLOW_MULTIPLE" intent filter:if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {final Intent intent = n...
转载请注明出处:codog_main的博客
有时我们想选择文件,但是又懒得自己去写一个文件浏览器,使用安卓原生的文件选择器或引入第三方库无疑是最佳选择,因为写自己不喜欢的东西真的非常痛苦。
安卓开启系统原生文件浏览器的教程网上已经烂大街了,但是很少有文章提及如何进行多选文件。我们在开启原生的文件浏览器时,默认是单选的,即点击文件立即返回uri,想实现多选只需要加入语句:
inte
...
android
中调用系统图库本来是一个很基本的东西,几乎每个app都用的到(最基本的更换用户头像),网上的相关内容很多,本来找了几篇看了一下,拿几台测试机试了一下感觉就没什么问题了,但是适配问题慢慢就来了。
一.打开图库的基本方法。
通过查询资料,调用系统图库基本有3种方法。
1.使用
Inte
nt
.ACTION_
PIC
K
Inte
nt
i = new
Inte
nt
(
Inte
nt
.ACTION_