问题
How do i use intent in android widget to open images in browser.
回答1:
If the image is on the internet it would be as simple as this:
String url = "http://www.picturesnew.com/media/images/image-background.jpg";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
However if the image is inside of your assets you can't open it in the browser. That's because the browser accepts URI data that starts with http. Furthermore the browser is a separate app and one app can't use other apps assets.
You could dipslay the image through the use of a WebView though.
回答2:
To open a website from your widget:
Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.fakesite.com\articles"));
startActivity(intent);
来源:https://stackoverflow.com/questions/24968333/how-to-open-image-url-on-browser-using-android-widget