views:

34

answers:

1

I want to have an image open from a URL to an intent, most likely the browser or maybe a picture previewer like the one built into twidroyd.

Intent intent = new Intent();

Uri uri = Uri.parse("http://nssdc.gsfc.nasa.gov/image/planetary/earth/gal_new-zealand.jpg");

intent.setDataAndType(uri, "image/*");
intent.setAction(android.content.Intent.ACTION_GET_CONTENT);

startActivity(intent);

However when I try, I get the following exception:

ERROR/AndroidRuntime(232): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT dat=http://nssdc.gsfc.nasa.gov/image/planetary/earth/gal_new-zealand.jpg typ=image/* }

I've gotten plain URLs to open to the browser. I just can't figure out what action or category to specify, I've tried:

intent.addCategory("CATEGORY_BROWSABLE");
// and
intent.addCategory("CATEGORY_OPENABLE");

It also doesn't work if I set the action as:

android.content.Intent.ACTION_VIEW

Any Ideas?

+1  A: 

Setting the mime type might make the Intent matcher a little too specific based on how the browser sets up its filters. Trying using ACTION_VIEW, with the uri as data and do not set the mime type.

codelark
I should have just stuck with doing what I did for other urls. I thought maybe images would be handled special. Thanks!
Josiah Peters