Location updates and path tracking in Android

Introduction

In this era of rapidly changing technology, mobile devices have made their way into all spheres of an individual’s life. Their role in daily life has been increasing tremendously and they are being used for much more than the basic purpose of communication. Android has emerged into the mobile world with an intention to develop a mobile platform OS. It has a tremendous potential in developing smart phones which are aware of its owner’s location and preferences.

Knowing the user’s location is one of the most prominent feature that we have in Android. It can be used to track the path that user went through or to find the current location of a person to identify where he/she is.
Android has provided two API’s from which we can get the location of the device. In this blog, we are going to shed some light on the location API’s usage, working of location awareness in Android and how it will be useful in the real-time world.

The following are the main points which will be addressed in the later sections of the blog:

  • Why do we need to know user location?
  • What are the different ways to get a location in Android?
  • How do we get location data using available API’s?
  • Which one is the best among available location API’s?
  • What are the advantages and disadvantages of each location tracking API?

Why do we need to know user location?

User location comes in handy when a user should be tracked continuously.
Eg: In an Uber app, tracking the current location of the cab is made possible using continuous location
tracking. In a fitness app, user’s path can be known by getting continuous location updates.

In a certain context, an app might need location updates periodically. Let’s say we are building a direction app and the user needs to get updated whenever the location is changed. In such case, we need to request for location updates.

Like above-mentioned examples, location can be used in many areas and is deemed a powerful information for computing results and to make things easy for the user.

What are the different ways to get a location in Android?

There are two conventional ways by which we can get location updates in Android. They are:

  1. Location manager
  2. Fused Location Provider

How do we get location data using available API’s?

1. Location Manager:

Location Manager is an android framework class. It provides access to the system location services. It can get the location from GPS, NETWORK and WI-FI. But at a given time, it can get the location from only one provider.

State of platform API’s with Location manager:

System permissions required by Location Manager are

Java

1<uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”/>

2<uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”/>

Here is the code snippet for Location Manager

Click Here for More……

Osmosys Software Solutions

Written by

Osmosys software solutions is a 14 year old company providing the best services in the areas of Dynamics CRM, software development(web and mobile applications)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade