我正在构建一个需要单击按钮即可启动android内置文件系统应用程序的应用程序。我不确定该怎么称呼,它的标题为“ Documents”,并列出了设备上存在的所有文件。这是它的样子-
您添加的图像属于“文档”应用程序。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的更多信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句