-3

i'm just getting started with Android Studio. I want to know how can i access the broswer, giving it a certain URL (that in the future will be the IP address of an IP camera).

Phantômaxx
  • 36,442
  • 21
  • 78
  • 108
AndyShoes
  • 23
  • 10

2 Answers2

0

You can do following:

Intent intent= new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
startActivity(intent);
Sagar
  • 20,467
  • 4
  • 50
  • 56
0

Try this:

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

That works fine for me.

As for the missing "http://" I'd just do something like this:

if (!url.startsWith("http://") && !url.startsWith("https://"))
   url = "http://" + url;
Rohit5k2
  • 16,859
  • 8
  • 38
  • 56
  • Can we maybe *not* copy answers wholesale from duplicate questions? Or at least reference the person who initially has given the answer? – M. Prokhorov Apr 11 '18 at 13:46