如何通过ACTION_OPEN_DOCUMENT向更多提供商显示 [英] How to show more providers with ACTION_OPEN_DOCUMENT

查看:154
本文介绍了如何通过ACTION_OPEN_DOCUMENT向更多提供商显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用作为Storage Access Framework的一部分提供的android系统对话框来打开文件.我用

I want to use the android system dialog provided as part of the Storage Access Framework to open a file. I do this with

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/pdf");
startActivityForResult(intent, EDIT_REQUEST);

,然后在onActivityResult()中处理返回的URI.

and then handle the returned URI in onActivityResult().

问题在于,在出现的菜单中,我得到的内容提供程序比我预期的要少得多.仅Google云端硬盘和下载(请参见下面的左屏幕截图).其他未显示,例如Dropbox,Solid Explorer等.

The problem is that, in the resulting menu, I get far less content providers than I expected. Only Google Drive and Downloads (see left screen shot below). Others, like Dropbox, Solid Explorer,... are not show.

我怀疑原因是这些应用根本没有设置必要的意图过滤器以显示在此列表中.

I suspect the reason is that these apps simply don't set the necessary intent filter to show up in this list.

但是,其他应用程序(例如Kaiten Mail或Chrome)设法以某种方式显示了系统对话框,并在列表顶部显示了完全实现的内容提供程序,然后在其他应用程序(如Dropbox和Solid Explorer)下显示了细线(请参见右图).

However, other apps, for example Kaiten Mail or Chrome, somehow manage to show the system dialog with fully implemented content providers at the top of the list and then others, like Dropbox and Solid Explorer, below, separated by a thin bar (see the right screen shot).

如何获得这种行为?

推荐答案

使用'ACTION_GET_CONTENT:

Use 'ACTION_GET_CONTENT:

Intent intent = new Intent(Intent. ACTION_GET_CONTENT);
intent.setType("application/pdf");
startActivityForResult(intent, EDIT_REQUEST);

这篇关于如何通过ACTION_OPEN_DOCUMENT向更多提供商显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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