how to clear error android.content.ActivityNotFoundException: Unable to find explicit activity class

  Kiến thức lập trình

how to clear error i get this error android.content.ActivityNotFoundException: Unable to find explicit activity class html intent chrome webview error show

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 coding

        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);
                    }

LEAVE A COMMENT