From the course: Android Development: Understanding Intents

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Open a URL with the browser

Open a URL with the browser - Android Tutorial

From the course: Android Development: Understanding Intents

Start my 1-month free trial

Open a URL with the browser

- [Narrator] Now that we've seen an example of how to create an intent to launch one of the system applications such as the camera. Let's take a look at a similar example where we will launch a web browser to display a URL to the user. So here in my MediaActivity.Java class for my start version of my project, I've scrolled down to the button click handler for the open URL button and in this case we need to parse the URL that we have right here. This is the URL we're going to open. We need to parse this before we can give it to the intent so that it has the right format for the system to process. So, what I'm going to do is create a Uri and to do that I need the Uri class. So I'm going to create a Uri object and I'm going to call it webpage and then I'm going to use the Uri class as parse static function to parse the URL string that I've defined here. So that will give me a Uri object and now that I have that I can create the intent. So the action for this particular intent is…

Contents