We have previously demonstrated how to use a web API from your Android app, and we have also discussed how to get and use location data in your Android app. In this tutorial, we will utilize both of these lessons, and show how you can track a device’s location using a remote web API. The remote web API we selected is the Thingspeak API.
For this article, we will develop an Android application that gets the device’s location information, and sends the latitude/longitude data to a ThingSpeak channel. We will then fetch the last location data from the ThingSpeak channel, and compute the distance from the last updated location to a location entered by the user. A simple (and obvious) use of this is parents who wish to track their children, or employers tracking employees. The ThingSpeak channel can also be viewed using a browser.