Android8.0以后打开文件管理器并跳转到指定路径的方法

String path = "%2fDCIM%2fCamera%2f";
Uri uri = Uri.parse("content://com.android.externalstorage.documents/document/primary:" + path);
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");//想要展示的文件类型
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri);
startActivityForResult(intent, 0);

PS:正常文件路径是DCIM/Camera这样的,在这里需要把/替换成%2f。

猜你喜欢

转载自blog.csdn.net/mozushixin_1/article/details/109223066