I get a strange error when I try to open a local HTML file in an Android browser. An error occurred: an exception not found in the activity:
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?
What is really strange for me is that this error does not occur on all devices. It appears only on the following devices:
- Samsung Galaxy Nexus i (4.1.1)
- Samsung Galaxy Nexus II (4.1.1)
- Sony Tablet S (4.0.3)
I have successfully verified my code on the following devices:
- Samsung Galaxy S i (4.1.1)
- Samsung Galaxy S III
- HTC One X
- HTC Desire S
- Samsung Galaxy S Plus (2.3.3)
- Samsung Galaxy Tab 10.1N
- AVD with Android versions 2.3.3 to 4.1.0
Finally, this is the code that I use to open my HTML file with an Android browser. I tested several permutations of this code, leaving some lines, but they all have the same effect. As soon as I install the component or class, I get the exception above.
Uri uri = Uri.parse(filePath); Intent browserIntent = new Intent(Intent.ACTION_VIEW); browserIntent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); browserIntent.setDataAndType(uri, "text/html"); browserIntent.addCategory(Intent.CATEGORY_BROWSABLE); context.startActivity(browserIntent);
I also tried
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
instead
browserIntent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
But with the same effect ...
Does anyone have an idea why this is happening, am I missing something? I searched for days on this, but could not find anything that solved my problem ...
Thank you very much in advance, greetings
android browser android-activity exception
Henning
source share