Using Location Data

All three platforms expose robust APIs that allow you to easily tap into the user’s current location within your applications. Despite the fact that all three of these APIs are independent of one another, there are many things they have in common, both in how they obtain the data and best practices for how to approach designing your application.

There are three sensors available for devices to determine the current location:

  1. Cellular signal

  2. Wi-Fi connection

  3. GPS signal

These sensors are listed in increasing order of accuracy, so GPS provides the finest level of precision and cellular signal the coarsest. Naturally, this has implications for how you should approach building your apps in order to provide the best possible user experience.

Accuracy

As is often the case, with great power comes great impact on battery life. When designing a location-aware application, you should think about the level of accuracy you need in the user’s location. Obtaining finer location information requires using more accurate sensors, which in turn consumes more power. For example, if you were building a weather application you might only care about the region a user was in rather than the street she is standing on. As such, there is no need to fire up the expensive GPS sensor when a cheaper one will suffice.

Frequency

Along the same lines, another thing to keep in mind is how often you need location updates. You can think of this frequency not just in terms of a polling time interval but also ...

Get Mobile Development with C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.