如何在 android 中的 Chrome 浏览器上从应用程序数据查看 HTML 文件
How to view HTML file from application data on Chrome Browser in android
我正在执行 Android 应用程序,我想在 Chrome 浏览器上从我的应用程序数据中打开一个 HTML 文件,而无需手动中断。目前它在默认情况下工作正常 browser.But 我想在 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 浏览器 explicitly.If 上进行操作 我试过 setClassName("com.android.chrome", "com.android.chrome.Main")
,但出现异常
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW..." .
请帮我解决这个问题。还有其他办法吗?谢谢。
设置classname
为
com.android.chrome/com.google.android.apps.chrome.Main
browserIntent.setClassName("com.android.browser", "com.android.chrome/com.google.android.apps.chrome.Main");
我正在执行 Android 应用程序,我想在 Chrome 浏览器上从我的应用程序数据中打开一个 HTML 文件,而无需手动中断。目前它在默认情况下工作正常 browser.But 我想在 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 浏览器 explicitly.If 上进行操作 我试过 setClassName("com.android.chrome", "com.android.chrome.Main")
,但出现异常
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW..." .
请帮我解决这个问题。还有其他办法吗?谢谢。
设置classname
为
com.android.chrome/com.google.android.apps.chrome.Main
browserIntent.setClassName("com.android.browser", "com.android.chrome/com.google.android.apps.chrome.Main");