Pha*_*tom 4 android file-manager android-intent
如何重定向我的应用程序以在特定路径打开文件管理器?
我尝试过类似的东西:
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("*/*");
shareIntent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(new File(filePath)));
shareIntent.setPackage("my.package");
startActivity(shareIntent);
Run Code Online (Sandbox Code Playgroud)
但我一直得到错误:
E/AndroidRuntime(3591):android.content.ActivityNotFoundException:找不到处理Intent的活动{act = android.intent.action.SEND typ = / flg = 0x1 pkg = my.package(has clip)(有附加内容)}
什么是正确的意图过滤器,因为我怀疑ACTION_SEND不正确.
谢谢.
你可以使用Intent.ACTION_GET_CONTENT:
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse("/whatever/path/you/want/"); // a directory
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));
Run Code Online (Sandbox Code Playgroud)
Actually this days it's more like:
// Construct an intent for opening a folder
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(aDownloadFolder), "resource/folder");
// Check that there is an app activity handling that intent on our system
if (intent.resolveActivityInfo(aContext.getPackageManager(), 0) != null) {
// Yes there is one start it then
startActivity(intent);
} else {
// Did not find any activity capable of handling that intent on our system
// TODO: Display error message or something
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8621 次 |
| 最近记录: |