【发布时间】:2016-07-31 09:06:21
【问题描述】:
要启动文件管理器应用程序以便用户选择他们想要打开的文件,我使用以下代码:
Intent pickFile = new Intent(Intent.ACTION_GET_CONTENT);
pickFile.setType("file/*");
pickFile.addCategory(Intent.CATEGORY_OPENABLE);
if (pickFile.resolveActivity(getPackageManager()) != null) {
startActivityForResult(pickFile,FILE_REQUEST_CODE);
} else{
Toast.makeText(getApplicationContext(),"Did not start intent",Toast.LENGTH_SHORT).show();
return;
}
这很好用。但文件管理器会在根目录中打开。
对于用户来说,这需要点击太多才能获得所需的文件。
那么有没有办法从不同的文件夹而不是根目录启动 Intent?此外,Android Developer Guide 似乎没有提供解决方案。
【问题讨论】:
标签: android android-intent file-manager