Saturday, December 10, 2011

[android-developers] Open Browser with HTML page from sdcard

Hi,
I need to open a html file that sits on my sdcard in my default
browser.

The code works fine if the file is on the net or in my asset folder,
but if I want to open it from the sdcard I get an
12-11 08:06:34.650: E/AndroidRuntime(6829):
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.VIEW
cat=[android.intent.category.BROWSABLE] dat=content:///mnt/sdcard/
download/stocks.html?text/html }

// String url = "file:///android_asset/stocks.html";
// String url = "file:///mnt/sdcard/
download/stocks.html";
String url = "content:///mnt/sdcard/download/stocks.html?text/
html";
//File sdCard = Environment.getExternalStorageDirectory();
//File dir = new File(sdCard.getAbsolutePath() + "/download/
stocks.html");

Intent i = new Intent(Intent.ACTION_VIEW);
i.addCategory("android.intent.category.BROWSABLE");
i.setData(Uri.parse(url));
startActivity(i);

Anything else I need to set on the Intent to make it realize that I
want to open a browser?
Thanks,
Stephan

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate