How can I add GPS service to my application?
- 07 Feb 2024
- 1 Minute to read
- Contributors
- Print
- DarkLight
How can I add GPS service to my application?
- Updated on 07 Feb 2024
- 1 Minute to read
- Contributors
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
The Blade pulls GPS location data from a linked companion device.
As such, you will need to define a location listener:
private final LocationListener mLocationListener = new LocationListener() {
@Override
public void onLocationChanged(final Location location) {
//your code here
}
};
Then utilize the LocationManager API to register for updates:
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, LOCATION_REFRESH_TIME, LOCATION_REFRESH_DISTANCE, mLocationListener);
And finally, add the permissions to access the data by adding one of the following to your manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
or
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
Was this article helpful?