How to open image url on browser using android widget

 ̄綄美尐妖づ 提交于 2020-01-05 12:12:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!