2014.01.17
前几天遇到一个需求:在SB Notes项目中需要点击一个Button调用默认的浏览器打开指定的url。
我认为需要注意的几点:
1、有无网络的情况
2、对于pop up出来的Window各种分辨率下的布局
3、倘若设备上未安装浏览器
尝试方法一:
Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); Uri content_url = Uri.parse("https://saddleback.v2s.mobi/"); intent.setData(content_url); intent.setClassName("com.android.browser","com.android.browser.BrowserActivity"); startActivity(intent);
在Kindle Fire中调试失败。
尝试方法二:
final Uri uri = Uri.parse("https://saddleback.v2s.mobi/"); final Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it);
现有所有设备都调试成功。
thanks
jack.lee
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.