Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.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-Can';无法使用指定的本地文件打开chrome,但可以在chrome打开时访问文件_Android_Google Chrome_Android Intent - Fatal编程技术网

Android-Can';无法使用指定的本地文件打开chrome,但可以在chrome打开时访问文件

Android-Can';无法使用指定的本地文件打开chrome,但可以在chrome打开时访问文件,android,google-chrome,android-intent,Android,Google Chrome,Android Intent,我使用此代码打开具有指定本地文件的浏览器 String url = "file:///storage/sdcard0/Files/AppFolder/main.html"; Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

我使用此代码打开具有指定本地文件的浏览器

        String url = "file:///storage/sdcard0/Files/AppFolder/main.html";
        Uri uri = Uri.parse(url);  

        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setPackage("com.android.chrome");

        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException ex) 
            intent.setPackage(null);
            wrapper.startActivity(intent);
        }
这是行不通的;我收到一个错误“无法打开该文档,因为它不是有效的PDF文档”。出于某种原因,adobe reader尝试打开文件而不是chrome

如果我使用“”,chrome将打开Facebook,然后我可以file:///storage/sdcard0/Files/AppFolder/main.html“它将打开我的main.html文件


有人能告诉我为什么我无法使用指定的本地url打开chrome吗?

您是否检查了硬编码路径是否正确?是的,路径是否正确,当浏览器已经打开时,我可以使用该路径打开文件(即,我在broswers文本字段中键入该路径)