如何在我的应用程序中打开broswer?

时间:2018-04-10 14:22:54

标签: java android

我刚刚开始使用Android Studio。我想知道如何访问broswer,给它一个特定的URL(以后将是IP摄像机的IP地址)。

2 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
startActivity(intent);

答案 1 :(得分:0)

试试这个:

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

这对我来说很好。

至于缺少的“http://”我会做这样的事情:

if (!url.startsWith("http://") && !url.startsWith("https://"))
   url = "http://" + url;
相关问题