【问题标题】:Android 4.0 is not giving option to choose app for opening a file?Android 4.0 没有提供选择打开文件的应用程序的选项?
【发布时间】:2013-04-17 05:41:13
【问题描述】:

我正在一个项目中工作,我需要在列表视图中显示 SD 卡中存在的所有文件的列表,并单击列表视图项为用户提供选择用于打开该文件的应用程序的选项。下面是我正在使用的代码。它在 Android 2.3.3 中运行良好。但 Android 4.0 及更高版本会在图库照片查看器中打开所有文件。请指教。

@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);

    }

【问题讨论】:

    标签: android file sd-card


    【解决方案1】:

    使用startActivity(Intent.createChooser(intent,"dialog title")) 启动选择器。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-09-04
        • 2023-03-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多