打开文件夹 - 意向选择器 [英] Open Folder - Intent chooser

查看:89
本文介绍了打开文件夹 - 意向选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何打开一个对话框,列出所有的应用程序,可以打开一个给定的文件夹?

我试过以下code

 意向意图=新意图(Intent.ACTION_GET_CONTENT);
intent.setData(Uri.fromFile(Environment.getExternalStorageDirectory()));
startActivity(Intent.createChooser(意向,打开文件夹));

它说:没有应用程序可以执行此操作。

我的设备有默认的文件管理器和应用程序AndroidZip(这些应用程序可以打开一个文件夹)。


解决方案

  

它说:没有应用程序可以执行此操作。


这是不足为奇的。你是不是要求打开文件夹,因为没有这样的事情在意图系统中的文件夹。您正在试图找出哪些应用程序可以打开的路径,没有文件扩展名并没有MIME类型。有没有在设备上安装应用程序有一个<意向滤光器> 在支持的活动 ACTION_GET_CONTENT 上有没有文件扩展名并没有MIME类型的路径。

您可以尝试 ACTION_VIEW 。但是,请记住,我估计,Android设备的90%以上将一无所有,在这种方式与文件夹交易,无论是。

How to open a dialog that list all applications that can open a given folder?

I tried following code

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setData(Uri.fromFile(Environment.getExternalStorageDirectory()));
startActivity(Intent.createChooser(intent, "Open Folder"));

it says "No applications can perform this action."

My device has default File Explorer and AndroidZip applications (these apps can open a folder).

解决方案

it says "No applications can perform this action."

That is not surprising. You are not asking to open a "folder", as there is no such thing as a "folder" in the Intent system. You are trying to find out what applications can open a path with no file extension and no MIME type. There are no applications installed on your device that have an <intent-filter> on an activity that supports ACTION_GET_CONTENT on a path with no file extension and no MIME type.

You might try ACTION_VIEW. However, bear in mind that I would estimate that 90+% of Android devices will have nothing that deals with "folders" in this fashion, either.

这篇关于打开文件夹 - 意向选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆