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.

Show a location on a map

Show a location on a map - Android Tutorial

From the course: Android Development: Understanding Intents

Start my 1-month free trial

Show a location on a map

- [Instructor] I'm going to wrap up this chapter by demonstrating how to display a location using a Maps app. So here in my AppsActivity.java code, I have a string variable that contains a latitude and a longitude using the geo protocol. So to create a Uri that I can pass to an intent, I'm going to use the Uri class to parse this string. So let's go ahead and start off by doing that. So I'll use the Uri class to create a geoLocUri variable, and then I'll just call the parse function and I'm going to parse the location string. So then I'm going to create an intent that uses the ACTION_VIEW command and takes the Uri directly as a parameter. So that's the ACTION_VIEW and I'll just simply pass in the geoLocUri. Okay, so, this code kicks off the intent which will bring up the Maps application and display the location. Now we're starting off with a pretty basic location here just a lat. and a long., so let's go ahead and try that out. I'll click on the debug and we'll bring up the emulator.…

Contents