+ 1

How to open web page with a click of each navigation item from NavigationItemSelected in android

When selecting the navigation activity in android studio, I saw in the MainActivity.java that there was a conditional if statement for each nav item selected but I want each to open a web page, how do I go bout that

16th Sep 2017, 6:33 AM
Lini Benson Jr
Lini Benson Jr - avatar
1 Answer
0
Hi, i suppose those items work like buttons, they trigger an event when pressed, you could use this piece of code inside those events : String url = "http://www.someurl.com"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); what it does, is fire an intent to open the url given, using your default browser
26th Sep 2017, 1:08 AM
Pablo Saavedra R
Pablo Saavedra R - avatar