I'm encountering a strange error when I try to open a local HTML - file in the android browser. The error that occurs is an activity not found exception:
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's really strange to me ist the fact that this error does not occur on all devices. It only comes up 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 tested my Code successfully 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
- AVDs with Android Versions ranging from 2.3.3 to 4.1.0
Finally this is the Code I'm using to open my HTML - file with the Android - browser. I have tested several permutations of this code, leaving out some lines, but they do all have the same effect. As soon as I set component or class I getting the above exception.
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 have also tried
browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
instead of
browserIntent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
But with the same effect...
Has someone an idea why this is happening, am I missing something? I have searched for days on this but couldn't find anything that solved my problem...
Thanks a lot in advance, cheers