选择与Intent.ACTION_GET_CONTENT多个文件 [英] Select multiple files with Intent.ACTION_GET_CONTENT
问题描述
我想选择有意向多个文件,但它似乎像我缺少的东西。
我创建一个Intent.ACTION_GET_CONTENT意图,把Intent.EXTRA_ALLOW_MULTIPLE作为额外的
(它似乎完全适合的目的),并创建一个选择器(可选),它选择应该是能挑到多个文件,并返回它们的应用程序。
问题是,我只能选择一个单一的文件。
我试过多种文件探险家。 这是API 18(4.3)。
ACTIVITY_CHOOSE_FILE = 1; //全局常量
按钮BTN =(按钮)this.findViewById(R.id.btnGetFiles);
btn.setOnClickListener(新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
意图chooseFile;
意向意图;
chooseFile =新的意图(Intent.ACTION_GET_CONTENT);
chooseFile.setType(文件/ *);
chooseFile.putExtra(Intent.EXTRA_ALLOW_MULTIPLE,真正的);
意图= Intent.createChooser(chooseFile,选择文件);
startActivityForResult(意向,ACTIVITY_CHOOSE_FILE);
}
});
我还添加了这个以清单(它有相同的功能添加它之前):
<意向滤光器>
<作用机器人:名称=android.intent.action.GET_CONTENT/>
<类机器人:名称=android.intent.category.DEFAULT/>
&所述; /意图滤光器>
我为什么不能选择多个文件?
(为澄清:问题不是,多个文件都没有回来 - 我不能选择超过1文件)
我为什么不能选择多个文件?
presumably,的implemeters的应用程序,它应该能够选择多个文件,并返回他们还没有实施 EXTRA_ALLOW_MULTIPLE
支持。与他们联系,要求此功能。
I'm trying to select multiple files with an Intent, but it seems like I'm missing on something.
I create an Intent.ACTION_GET_CONTENT Intent, put Intent.EXTRA_ALLOW_MULTIPLE as extra in
(it seems to perfectly fit the purpose) and create a chooser (optional), which chooses the application that should be able to pick multiple files and return them.
The Problem is that I can only pick a single file.
I tried multiple file explorers. It's API 18 (4.3).
ACTIVITY_CHOOSE_FILE = 1; //global constant
Button btn = (Button) this.findViewById(R.id.btnGetFiles);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent chooseFile;
Intent intent;
chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("file/*");
chooseFile.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent = Intent.createChooser(chooseFile, "Choose a file");
startActivityForResult(intent, ACTIVITY_CHOOSE_FILE);
}
});
I also added this to the Manifest (it had the same functionality before adding it):
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Why can't I choose multiple files?
(For clarification: the problem is not, that multiple files aren't returned - I can't choose more than 1 file)
Why can't I choose multiple files?
Presumably, the implemeters of "the application that should be able to pick multiple files and return them" have not implemented EXTRA_ALLOW_MULTIPLE
support. Contact them and request this feature.
这篇关于选择与Intent.ACTION_GET_CONTENT多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!