Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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的Chrome浏览器上查看应用程序数据中的HTML文件_Android_Android Intent - Fatal编程技术网

如何在android的Chrome浏览器上查看应用程序数据中的HTML文件

如何在android的Chrome浏览器上查看应用程序数据中的HTML文件,android,android-intent,Android,Android Intent,我正在做Android应用程序,我想在Chrome浏览器上从我的应用程序数据中打开一个HTML文件,而不需要手动中断。目前它在默认浏览器中运行良好。但我想在chrome浏览器上打开它 默认浏览器的我的代码: Intent browserIntent = new Intent(Intent.ACTION_VIEW); browserIntent.setData(Uri.fromFile(file)); browserIntent.setType("text/html"); browserInten

我正在做Android应用程序,我想在Chrome浏览器上从我的应用程序数据中打开一个HTML文件,而不需要手动中断。目前它在默认浏览器中运行良好。但我想在chrome浏览器上打开它

默认浏览器的我的代码:

Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setData(Uri.fromFile(file));
browserIntent.setType("text/html");
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");                                                      
browserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(browserIntent);
我怎样才能在Chrome浏览器上明确地执行该操作。如果我像setClassNamecom.android.Chrome、com.android.Chrome.Main那样尝试,我会得到一个异常

android.content.ActivityNotFoundException:找不到可处理Intent的活动{act=android.Intent.action.VIEW

请帮我解决这个问题。还有其他办法吗?谢谢。

将classname设置为

com.android.chrome/com.google.android.apps.chrome.Main


如果Chrome没有安装在设备上怎么办?记住,即使谷歌问你在哪里打开youtube链接broswer/s和youtube应用程序,这意味着你可以控制显示链接的内容等。但用户想在哪里看到链接是用户的选择。即使我们可以做到,我们也不应该。amit,我的应用程序最初检查Chrome是否安装在设备上或者不是。那么只有它显式地打开那个html文件。
browserIntent.setClassName("com.android.browser", "com.android.chrome/com.google.android.apps.chrome.Main");