如何清除错误,我收到此错误 android.content.ActivityNotFoundException:无法找到显式活动类 html 意图 chrome webview 错误显示
Process: com.Heart.Recipes, PID: 32697
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.browser/com.android.browser.BrowserActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2171)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1805)
意图编码
Intent i = new Intent();
// MUST instantiate android browser, otherwise it won't work
i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
i.setAction(Intent.ACTION_VIEW);
String html = "<html><body>hello World</body></html>";
// May work without url encoding, but I think is advisable
// URLEncoder.encode replace space with "+", must replace again with %20
String dataUri = "data:text/html," + URLEncoder.encode(html).replaceAll("\\+","%20");
i.setData(Uri.parse(dataUri));
startActivity(i);
try {
startActivity(i);
} catch (ActivityNotFoundException e) {
// Chrome is probably not installed
// Try with the default browser
i.setPackage(null);
startActivity(i);
}
您需要删除此行:
i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
想必,你有那条线是因为这个原因:
// MUST instantiate android browser, otherwise it won't work
相反,您需要修复剩余的行,以便您尝试执行的任何操作都可以与其他浏览器一起使用。
BrowserActivity
不仅在您的设备上不存在,在 Android 中也不存在,并且不需要用户安装具有该应用程序 ID 的应用程序。