Viv*_*ngh 8 android android-intent
我是Android的新手,我要求在API级别19以下的设备上选择文件.
我试过了
private void chooseFile() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
intent.setType("application/pdf|file");
} else {
intent.setType("image/*|application/pdf");
}
startActivityForResult(intent, PICKFILE_REQUEST_CODE);
}
Run Code Online (Sandbox Code Playgroud)
现在我不希望Google驱动器作为选项出现,我想要文件管理器作为选项.我想用意图来做这件事.
任何人都可以建议我如何实现这一目标?
Spe*_*eed 16
你有没有尝试过
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
Run Code Online (Sandbox Code Playgroud)
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
//intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
intent.setType("application/pdf");
startActivityForResult(intent, PICKFILE_REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)
这将有助于我避免选择器中的 gdrive
归档时间: |
|
查看次数: |
2230 次 |
最近记录: |