android - 在 chrome 浏览器中打开一个 html 页面

标签 android google-chrome android-browser

如何在 chrome 浏览器中打开位于我的应用程序数据中的 html 页面?对于默认浏览器,我使用以下代码 -

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 浏览器上不起作用。如何在 chrome 浏览器中打开相同的 html 页面。

提前致谢

最佳答案

您不能指定用户应该使用哪个浏览器。你的代码是正确的。然后将向用户显示一个小对话框,用户可以在其中选择已安装的浏览器之一。 如果您没有看到此对话框,那么您已经保存了您的选择以始终使用它。

关于android - 在 chrome 浏览器中打开一个 html 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20476257/

相关文章:

html - 两个相互叠加的选择不适用于较旧的 Android 设备

android - 无法让 SipDemo 注册 sip 语音通话

android - 在锁定屏幕中无法单击通知操作按钮

java - 无法启动 Activity - ComponentInfo 错误

javascript - document.getElementById 返回 null

google-chrome - Google Chrome扩展程序中的onbeforeunload事件是否会触发popup.html?

css - 仅在 CSS 中定位 android 浏览器

android - 错误 :duplicate files during packaging of APK in android studio

javascript - document.title 的替代品?

html - Android 设备浏览器中具有一些额外像素值的复选框