通过Intent从文件管理器中选择文件

Pix*_*_95 9 android file android-intent

我想做什么:

我想把路径作为文件的字符串,我通过Android文件管理器选择.

是)我有的:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(Intent.createChooser(intent, "Open with ..."), FILE_SELECT_CODE);
Run Code Online (Sandbox Code Playgroud)

这段代码对我来说效果不错,但有一个问题.我只能使用以下应用选择我的文件:

在此输入图像描述

我的问题:

有没有人有通过Android文件管理器选择任何文件的工作代码?

Aak*_*ash 18

用这个:

    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("*/*"); 
    startActivityForResult(intent, REQUEST_CODE);
Run Code Online (Sandbox Code Playgroud)

对于三星设备打开文件管理器使用此:

Intent intent = new Intent("com.sec.android.app.myfiles.PICK_DATA");
intent.putExtra("CONTENT_TYPE", "*/*");
intent.addCategory(Intent.CATEGORY_DEFAULT);
Run Code Online (Sandbox Code Playgroud)

有关更多参考信息,请访问http://developer.android.com/guide/topics/providers/document-provider.html