markgg

Android 打开默认浏览器方式

Android 打开默认浏览器之前打开方式如下

1 Intent intent= new Intent(); intent.setAction("android.intent.action.VIEW");
2 Uri content_url = Uri.parse(url);
3 intent.setData(content_url);
4 intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
5 startActivity(intent);

在某些手机上程序自动退出,错误信息如下

Unable to find explicit activity class {com.android.browser/com.android.browser.BrowserActivity}; have you declared this activity in your AndroidManifest.xml?

1 Intent intent= new Intent(); intent.setAction("android.intent.action.VIEW");
2 Uri content_url = Uri.parse(url);
3 intent.setDataAndType(content_url, "text/html");
4 intent.addCategory(Intent.CATEGORY_BROWSABLE);
5 startActivity(intent);

 

分类:

技术点:

相关文章:

  • 2021-10-28
  • 2021-11-22
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-12-28
猜你喜欢
  • 2022-01-22
  • 2021-06-14
  • 2022-12-23
  • 2021-04-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案