Find your location
- Last UpdatedApr 28, 2025
- 3 minute read
This guide describes how to use native positioning with the HERE SDK.
When building location-aware applications, one of the most common tasks is to show the current location of the user on a map. For this, there are many different solutions available. One possible way is to use the android.location.LocationManager
to get locations from the device's built-in GPS sensors.
Note
- Note that some Android devices do not have a GPS sensor and may fallback to Wi-Fi positioning using a
NETWORK_PROVIDER
.- If GPS is available, some Android devices allow to improve the location accuracy. For this, go to Settings -> Location Services -> Google Location Accuracy - or similar.
The HERE SDK works smoothly with any proprietary or platform positioning solution. Note that a comprehensive HERE positioning solution is available as part of the Navigate Edition. A possible platform dependent implementation is shown below.
Before accessing the device's sensors, you need to ask the user for permission. Add the following permissions to your AndroidManifest
file:
For all example apps accompanying this user guide, we use a convenience class called PermissionsRequestor
which takes care of the task to request the user's permission. To learn more, see the Initialization and Android permissions section.
Next, get an instance of the LocationManager
from the Android platform and request location updates depending on the capabilities of the device:
If GPS is not available or disabled by the user, we fallback to Wi-Fi positioning which will be much less accurate. If even that is turned off, we give up.
As you can see from above, we set the calling class as the listener, so we need to implement the LocationListener
interface to start getting events:
platformLocationListener
is an interface we have defined to enable another class to easily get notified.
This is just an example of how to integrate a LocationManager
that provides access to the Android location services. Feel free to adapt it to your own needs.
Below you can find the complete class:
To integrate this class in your own app, create a new instance:
You can then start locating and hook in a listener:
To stop listening, call:
Note that our class receives android.location.Location
events. Use the following method to convert them to the Location
class used by the HERE SDK to cover the most common fields:
For more information on the LocationManager
and how to utilize other platform positioning features, please refer to the official Android documentation.