Developer’s Astonishing Experience With GPS Tracking and HERE SDK

gps maps 1

At some point in your career, you probably have to work on a project where you need to track a device’s location. Before starting your work, you’ll spend quite some time going through blogs and documentation about location tracking, GPS tracking, and all those things.

For new developers, google play services API can be the way to go. It contains several google related APIs such as maps, location, navigation, and many more. But sometimes, when we want more than just device tracking or location updates, the features provided by google play services might be a bit insufficient.

Quick link to the content

Purpose of this blog

The main purpose of this blog is to help new developers by bringing to their notice other libraries and APIs that are out there related to location tracking besides google play services. I will also discuss how and what features of HERE SDK I used personally in the Wolfmatrix project. I believe the readers will benefit from this article as it not only puts light on GPS tracking in Android and HERE’s location library along with its usage but also saves you a lot of time spent going through several blogs and documentation to find out what you need for your project. In this blog, I have mentioned why and how I used HERE’s location library. After reading this, readers will know what HERE library is and in what scenarios it’ll be handy.


What is GPS Tracking used for?

Developer's Astonishing Experience With GPS Tracking and HERE SDK

GPS tracking is a hot topic these days in almost every app. Most mobile apps have some sort of tracking mechanism for tracking the user’s location or their movement. These are extremely useful in many cases like when your phone has been lost or stolen.

Be it tracking vehicle movement or tracking some waiter’s journey along the way for delivering food for the restaurant business, their position is continuously traced and tracked. Clients track their driver’s journey for many reasons. It helps the company to decrease the wear and tear of the vehicles, improve driving safety, faster emergency response times, accurate and auditable service performance records, etc. It, in turn, reduces vehicle and equipment maintenance costs, tampering and thefts.


GPS tracking in Android

Earlier, getting the location was very easy with a couple of API calls. Later, to provide more accurate locations and to optimize battery usage, Android introduced a set of APIs (google play services for location) google play that should be combined to get the best results from the location API. In Android, the most common library to get users’ locations is:

implementation ‘com.google.android.gms:play-services-location:15.0.1’

It uses Fused Location API that combines signals from GPS, Wi-Fi, and cell networks, an accelerometer, gyroscope, magnetometer and other sensors to provide more accurate results. An app can get the location update based on several criteria like location setting, update interval, fastest update interval and priority.

Why not Google location services?

1. Interval for location update

The android app that I had to work on required a feature where the driver’s location had to be tracked continuously. Plus it had to send a notification once the driver gets in or out of the pre-set virtual geofence.

Working with Google’s location service, I felt its smallest interval for location update is a bit large for me. And it was not accurate enough too. Now the problem is that the vehicle would be moving at high speed, say 50 mph (around 80 mph), but the geofence that was set usually only had a 50 to 60 meters radius. The driver’s location updates should be very high, in our case, every 1 to 2 seconds because the vehicle moving at 80 mph would cross the geofence of a 60m radius in no time.

We can create geofence using the same google gms play services with a few boilerplate codes. Now the major area of concern is: firstly, getting the location updates of the driver’s vehicle at short intervals and secondly, creating geofence of a certain radius and getting notified when the driver gets in or out of the geofence at high speed.

2. Less code and performance issues

I needed something that required less code. Also, I needed some sort of mechanism that could handle both aspects with less fuss without having to worry about code optimization and device performance issues. Google location service API has usage limits of about 100 geofences per device, which was not enough for me. Additionally, running the google play services app in the background can cause battery drainage. And my app had to continuously listen for location changes in the background.

3. Minimum radius

There was one more reason why I had to search for an alternate solution. In google services documentation, its mentioned that for best results, the minimum radius of the geofence should be set between 100-150 meters. But our project had set a benchmark for geofence radius of minimum of 50 meters.

via GIPHY

After going through these numbers of drawbacks, I had to look for another approach for my project. That’s when I came across “HERE” API.


HERE API for Android

HERE is a complete location-based API and SDKs package for developers with features of highly accurate and interactive global maps, high precision location updates, device tracking, turn-by-turn navigation with real-time and historical traffic information, mobile navigation solutions, and many more.

Why did I choose HERE Location service?

HERE has everything that I needed for my app. It is not free, of course, with about 250K monthly transactions. But given that it provides positioning SDK for android and IOS for users to retrieve location updates, I was happy to pay the price.

HERE positioning SDK can provide rich location features based on Wi-Fi, Cellular, and BT network-based positioning, including features like Online Outdoor positioning, Online-Offline Hybrid Outdoor positioning, Indoor positioning, and Private Indoor positioning with fairly small intervals with the bulk of the work done by the SDK itself. Its advanced features include:

  1. Automatic positioning method switching between satellite-based (GNSS), Wi-Fi, Bluetooth, and cellular network positioning. That provided the best possible position information using the available methods.
  2. HERE Indoor Positioning supports both private and public data. You can have a private venue mapped through HERE Private Venues or your own custom indoor map, with the indoor location information only available for your applications. In contrast, indoor location information for public venues is available for all HERE SDK users with an appropriate license.
  3. Global positioning coverage and data hosting infrastructure for optimal availability, reliability, and user experience.

Here’s how I worked HERE

Of numerous features provided by HERE, my android app only required HERE’s positioning SDK and HERE GPS tracking API. So this article solely focuses on these two features. However, HERE has numerous other features like street maps, navigation, routing, geocoder, places, etc., which you can look at.

1. Getting location from Here’s positioning SDK

As mentioned in its documentation, HERE positioning SDK gives highly accurate location along with other information. Some of them are altitude accuracy, speed and timestamp in a reasonably short interval of time in comparison to Google’s location service.

To obtain the HERE Android SDK, register or login with your HERE account from site developer.here.com, find the section for HERE Android SDK Premium Edition and click on Generate App ID and App Code to obtain your app credentials and the SDK download link. Now download the HERE Android SDK library from the site developer.here.com and click on Get Started for Free to create the first HERE project.

  1. Register or sign in to your HERE account.
  2. Agree to the HERE Terms and Conditions.
  3. On the Platform Activation screen, follow the link to download the HERE Android SDK as a Zip package.

Using HERE positioning SDK, I can get the location updates of the driver’s vehicle at certain intervals. Now to produce a notification every time the driver’s vehicle enters or exits the geofence, we have to continuously send the driver’s location to the HERE server. In my project, the part of geofence creation is done through the backend. So for simplicity’s purpose, I will just explain the parts focusing on Android.

2. Sending location to HERE server

Now that we’re done with getting the location updates, the next part is to send those location updates to the server. Previously I had used HERE positioning SDK to get the location updates of the driver’s vehicle; now, for sending these locations to the HERE server, I am using HERE’s GPS tracking API. It provides yet another feature, tracking API, which exposes a set of REST APIs and client libraries. That enables location tracking and geofencing for various device form-factors, including small-footprint (small memory and processing power) devices. I’ve used android’s retrofit library to call API for sending locations you can use anything you want.

As I mentioned, geofence creation is done through our backend. All I had to focus on was regularly sending a location from the device. Before sending locations to HERE API, we must register our device to the HERE server. It will help HERE to track our particular device while sending notifications. I’m not going to explain the device registration process as it is well explained in HERE tracking documentation.

3. And Finally

Once the task of geofence creation, device registration and location sending is done, the rest of the work is done HERE. HERE continuously analyzes the device’s location and checks if it enters or exits the geofence it is registered to.

The event when the device enters or exits the geofence is termed a transition event. These transition events are stored in the transition log. These logs include all the events, including where a device almost crossed a geofence boundary. A webhook notification is created every time a device enters or exits an associated geofence. We can list all the devices associated with that particular HERE account and all geofences being created. We can also list all the geofences that a particular device is associated with, all transition events and many more. From here, we can monitor and analyze the devices, geofences and log transitions in HERE’s the graphical user interface.


My experience with HERE

roller coaster ride

Working with HERE was like a roller coaster ride. It has provided many features whereby HERE does the bulk of the work. That leaves just the task of configuring devices with a HERE account, authorizing users, creating geofences and sending locations.

Even though working with HERE was easy for me, it was tricky to kick-start it. I had to review their documentation several times before getting a hold of what I was looking for HERE. Their documentation is quite vast since they have several features. So it could be a bit tricky to get what we’re looking for from their documentation.


Lastly, you should know this.

After copying HERE’s AAR file to my project, my APK size ballooned from 3MB to 44MB. Its compressed AAR file contains several libraries in SO (shared object) format. All of these libraries go inside the APK.

And to reduce the size of my APK, I first removed a few unused libraries like libsMAPSJNI.so since my app did not have anything to do with maps; all I was using was the positioning feature.

Doing this caused my app to give an error message of libraries missing, and all HERE features stopped working. I guess HERE required it’s all libraries to be present in the app regardless of what feature you are using, which I found a bit strange.

Eventually, I had to configure APK for multiple ABIs generating separate APK for each ABI using splits block. While working in HERE, you might get a bit of a hard time searching for HERE-related questions and answers on StackOverflow; all you can do is put your questions in the issues section of HERE GitHub. 


Conclusion: Is HERE the best platform?

Now, of course, the question arises, is HERE the best platform for location and GPS tracking? The answer is it depends.

There are so many location-related libraries and frameworks available for different platforms. Interestingly, each framework has something better than the other or something that better suits your problem. HERE a framework is suited for my project. It may not be the best solution for you.

For me, working with HERE has been nothing but fun. Although I just used a few features of the vastly spread HERE platform, I gained so much knowledge about location GPS tracking and other cool features that HERE offers.

I strongly suggest you explore and try other features of HERE like navigation, routing, maps, etc. Not just HERE, there are so many location-based frameworks and libraries for GPS tracking available out there. Map box, radar, etc., are some of them.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top