Android - 如何以编程方式启动设备“文件系统”?

时间:2014-03-18 16:59:53

标签: android android-intent file-manager

我正在构建一个需要通过单击按钮启动android内置文件系统应用程序的应用程序。我不知道该怎么称呼,它说"文件"作为标题,列出设备上的所有文件。这就是它的样子 - enter image description here

1 个答案:

答案 0 :(得分:6)

您添加的图片是“文档”应用程序。 Android 4.4(API级别19)引入了存储访问框架(SAF)。 SAF使用户可以轻松浏览和打开所有首选文档存储提供程序中的文档,图像和其他文件。


您可以通过ACTION_OPEN_DOCUMENT

午餐
// ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file
// browser.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

// Filter to only show results that can be "opened", such as a
// file (as opposed to a list of contacts or timezones)
intent.addCategory(Intent.CATEGORY_OPENABLE);

// Filter to show only images, using the image MIME data type.
// If one wanted to search for ogg vorbis files, the type would be "audio/ogg".
// To search for all documents available via installed storage providers,
// it would be "*/*".
intent.setType("image/*");

startActivityForResult(intent, READ_REQUEST_CODE);

详细了解Storage Access Framework