admin管理员组文章数量:1026989
/**
* 调用第三方浏览器打开
* @param context
* @param url 要浏览的资源地址
*/
public static void openBrowser(Context context,String url){
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
// 注意此处的判断intent.resolveActivity()可以返回显示该Intent的Activity对应的组件名
// 官方解释 : Name of the component implementing an activity that can display the intent
if (intent.resolveActivity(context.getPackageManager()) != null) {
final ComponentName componentName = intent.resolveActivity(context.getPackageManager()); // 打印Log ComponentName到底是什么 L.d("componentName = " + componentName.getClassName());
context.startActivity(Intent.createChooser(intent, "请选择浏览器"));
} else {
Toast.makeText(context.getApplicationContext(), "请下载浏览器", Toast.LENGTH_SHORT).show();
}
}
/**
* 调用第三方浏览器打开
* @param context
* @param url 要浏览的资源地址
*/
public static void openBrowser(Context context,String url){
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
// 注意此处的判断intent.resolveActivity()可以返回显示该Intent的Activity对应的组件名
// 官方解释 : Name of the component implementing an activity that can display the intent
if (intent.resolveActivity(context.getPackageManager()) != null) {
final ComponentName componentName = intent.resolveActivity(context.getPackageManager()); // 打印Log ComponentName到底是什么 L.d("componentName = " + componentName.getClassName());
context.startActivity(Intent.createChooser(intent, "请选择浏览器"));
} else {
Toast.makeText(context.getApplicationContext(), "请下载浏览器", Toast.LENGTH_SHORT).show();
}
}
版权声明:本文标题:Android 调用第三方浏览器打开网址或下载文件 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1726856149a674457.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论