2013.03.19(8)———android 打开url 浏览器上载
2013.03.19(8)———android 打开url 浏览器下载
2013.03.19(8)———android 打开url 浏览器下载
参考:http://blog.****.net/lonely_fireworks/article/details/7379089
最近应用需要使用浏览器打开链接去下载东西,上网搜了一下 很多的代码,最常见就是:
但是 我用来之后 总是会报错:
因为 用户的手机环境可能不一样,默认的浏览器可能已经不存在了,所以 不能这么明确的指向,应该用隐式intent
2013.03.19(8)———android 打开url 浏览器下载
参考:http://blog.****.net/lonely_fireworks/article/details/7379089
最近应用需要使用浏览器打开链接去下载东西,上网搜了一下 很多的代码,最常见就是:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); this.startActivity(intent);
但是 我用来之后 总是会报错:
android com.android.browser.BrowserActivity not found
因为 用户的手机环境可能不一样,默认的浏览器可能已经不存在了,所以 不能这么明确的指向,应该用隐式intent
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent);