Rep*_*tor 5 android document android-intent android-gallery android-external-storage
目前我正在尝试从SD卡或任何应用程序中选择特定类型的文件,但我失败了,我的代码如下,
Intent intent;
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT)
intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
else
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/pdf|application/msword|application/vnd.openxmlformats-officedocument.wordprocessingml.document" +
"|application/vnd.openxmlformats-officedocument.wordprocessingml.template" +
"|application/vnd.ms-word.document.macroEnabled.12" +
"|application/vnd.ms-word.template.macroEnabled.12" +
"!application/vnd.ms-word.template.macroEnabled.12|application/rtf");
startActivityForResult(intent, Constants.ImagePicker.REQ_PICK_RESUME);
Run Code Online (Sandbox Code Playgroud)
但它只选择每种类型的文件.
试试这个代码:
Intent intent = new Intent();
intent.setType("application/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select file"),1 );
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
674 次 |
| 最近记录: |