Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何打开一个不充当文件选择器的文件管理器(具有给定文件夹)?_Android_Android Intent_File Manager - Fatal编程技术网

Android 如何打开一个不充当文件选择器的文件管理器(具有给定文件夹)?

Android 如何打开一个不充当文件选择器的文件管理器(具有给定文件夹)?,android,android-intent,file-manager,Android,Android Intent,File Manager,我试图打开一个文件管理器,它将显示我通过Intent发送给它的文件夹。文件管理器应该像一个文件管理器,而不是一个文件选择器,也就是说,一旦我决定从给定文件夹中选择一个文件,它将不会返回到我的应用程序,但它将提供标准选项,这些选项通常在从启动器图标启动文件管理器时可用 我尝试了以下方法: File folder = getOutputFolder(); Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

我试图打开一个文件管理器,它将显示我通过Intent发送给它的文件夹。文件管理器应该像一个文件管理器,而不是一个文件选择器,也就是说,一旦我决定从给定文件夹中选择一个文件,它将不会返回到我的应用程序,但它将提供标准选项,这些选项通常在从启动器图标启动文件管理器时可用

我尝试了以下方法:

        File   folder = getOutputFolder();
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        // I have tried: ACTION_VIEW, ACTION_GET_CONTENT, ACTION_OPEN_DOCUMENT

        Uri uri;
        if (Build.VERSION.SDK_INT >= 26) {

            String authority = getString(R.string.app_fileprovider);
            uri = FileProvider.getUriForFile(this, authority, folder);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        } else {
            uri = Uri.fromFile(folder);
        }

        // this with ACTION_GET_CONTENT, works as *picker* on API 28
        // on API 29 it does not open destination folder
        // intent.setData(uri); 

        intent.setDataAndType(uri, "*/*"); 
        // I have tried the following: image/*, file/*, */*, resource/folder
        // and DocumentsContract.Document.MIME_TYPE_DIR

        startActivity(Intent.createChooser(intent, getString(R.string.open_output_folder)));
我尝试过的所有组合都充当文件选择器,这不是我要寻找的。除此之外,有些组合会打开目标文件夹,有些则不会。行为也因API级别而异


有没有一种标准的方法来实现我所追求的目标?

“有没有一种标准的方法来实现我所追求的目标?”——我不知道。安卓设备不需要您描述的那种类型的通用文件管理器,从安卓SDK的角度来看,这一直是谷歌忽略的一个领域。
Intent.ACTION\u GET\u CONTENT
用于挑选文件。