Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.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 4.0没有提供选择应用程序打开文件的选项?_Android_File_Sd Card - Fatal编程技术网

Android 4.0没有提供选择应用程序打开文件的选项?

Android 4.0没有提供选择应用程序打开文件的选项?,android,file,sd-card,Android,File,Sd Card,我在一个项目中工作,我需要在列表视图中显示SD卡中存在的所有文件的列表,并单击列表视图项,让用户选择用于打开该文件的应用程序。下面是我正在使用的代码。它在Android 2.3.3中运行良好。但Android 4.0及以上版本会在gallery photo viewer中打开所有文件。请告知 @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

我在一个项目中工作,我需要在列表视图中显示SD卡中存在的所有文件的列表,并单击列表视图项,让用户选择用于打开该文件的应用程序。下面是我正在使用的代码。它在Android 2.3.3中运行良好。但Android 4.0及以上版本会在gallery photo viewer中打开所有文件。请告知

@Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
        // TODO Auto-generated method stub
        Uri path = Uri.parse("file://" + arrayListAllFilespath.get(arg2));
        //arrayListAllFilespath.add(listFile[i].getAbsolutePath());
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(path, "*/*");
        startActivity(intent);

    }
@覆盖
公共视图单击(AdapterView arg0、视图arg1、整型arg2、长型arg3){
//TODO自动生成的方法存根
uripath=Uri.parse(“文件:/”+arrayListAllFilespath.get(arg2));
//arrayListAllFilespath.add(listFile[i].getAbsolutePath());
意图=新意图();
intent.setAction(intent.ACTION\u视图);
intent.setDataAndType(路径“*/*”);
星触觉(意向);
}

这可能是因为您没有安装多个应用程序来打开映像。假设有多个应用程序来打开映像,则它会要求选择一个应用程序,但如果只有一个应用程序安装用于打开映像,则它会将其作为默认应用程序,从不询问您,或者如果您安装了多个应用程序然后,您可以将gallery设置为默认打开

这可能是因为您没有安装多个应用程序来打开图像。假设有多个应用程序来打开图像,则它会要求选择一个应用程序,但如果只有一个应用程序安装来打开图像,则它会将其作为默认应用程序使用,并且从不询问您,或者如果安装了多个应用程序,则可以将gallery设置为默认打开

使用
startActivity(Intent.createChooser(Intent,“对话框标题”))
启动选择器。

使用
startActivity(Intent.createChooser(Intent,“对话框标题”)
启动选择器