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

Suc*_*chi 2 android file-manager android-intent

我正在构建一个应用程序,只需单击一个按钮就可以启动android内置文件系统应用程序.我不知道该怎么称呼它,它将"Documents"作为标题并列出设备上的所有文件.这就是它的样子 - 在此输入图像描述

Pan*_*mar 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);
Run Code Online (Sandbox Code Playgroud)

阅读有关Storage Access Framework的更多信息.