O'Reilly logo

Xamarin 4.x Cross-Platform Application Development - Third Edition by Jonathan Peppers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Looking up GPS location

Using Xamarin.Mobile to track a user's GPS location is as simple as accessing their contacts. There is a similar process for setting up access on iOS and Android, but in the case of location, you don't have to request permission from code. iOS will automatically show the standard alert requesting permission. Android, on the other hand, merely requires a manifest setting.

As an example, let's add functionality to our XamSnap application that tags GPS location to messages within a chat conversation. You can think of this as tagging a location to a photo, as in other apps. Make sure to add Xamarin.Mobile to the project from the Component Store.

First, let's implement a Location class for storing latitude and longitude:

public ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required