如何以编程方式在android中打开目录
在我的应用程序中,我有ListActivity中显示的文件列表现在我想添加额外选项,如windows:(打开文件夹位置)要打开此文件的目录,我测试了一些代码但没有工作抛出异常:如何以编程方式在android中打开目录,android,android-intent,Android,Android Intent,在我的应用程序中,我有ListActivity中显示的文件列表现在我想添加额外选项,如windows:(打开文件夹位置)要打开此文件的目录,我测试了一些代码但没有工作抛出异常: File file=new File(path); Uri url = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(url); star
File file=new File(path);
Uri url = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(url);
startActivity(intent);
例外情况:
03-08 21:14:55.451: E/AndroidRuntime(15708):
android.content.ActivityNotFoundException: No Activity found to handle Intent {
act=android.intent.action.VIEW dat=file:///storage/extSdCard/Bluetooth }
我能做什么?但这不会适用于所有android file manager应用程序!setDataAndType需要类型?@kyle所选应用程序可以从应用程序本身打开文件吗?否意味着应该如何从所选应用程序本身打开文件?
public void openFolder()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/Bluetooth /");
intent.setDataAndType(uri);
startActivity(Intent.createChooser(intent, "Open folder"));
}