简体   繁体   English

如何打开默认浏览器

[英]How to open default browser

Can we make use of default browser instead of the WebView browser Is there ny API for the default browser..... 我们可以使用默认浏览器而不是WebView浏览器是否有默认浏览器的API ...

or we have to compulsory create our own browser through WebView 或者我们必须通过WebView强制创建我们自己的浏览器

You can use an Intent with ACTION_VIEW to open the browser with your URL. 您可以使用Intent with ACTION_VIEW使用您的URL打开浏览器。 Would be something like that : 会是这样的:

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));

You have to import intent. 你必须导入意图。

String url = "http://www.google.com";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse(value));
startActivity(i);

value is your URL address. value是您的URL地址。

This is a late answer but if you just need to open the default browser without an url you can use about:blank , ie: 这是一个迟到的答案,但如果您只需要打开没有网址的默认浏览器您可以使用about:blank ,即:

Intent blankIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("about:blank"));
startActivity(blankIntent);

Tested with: 经测试:

Stock Browser, Chrome, Firefox and Opera for Android 适用于Android的Stock浏览器,Chrome,Firefox和Opera

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM