How can I programmatically reset and download new A-GPS data in an Android application? In other words, how do the "Manage A-GPS state" tools work in the GPS Status & Toolbox app?
Clear AGPSInstall the free app GPS Test from the Google Play Store. It's a free app that you can later uninstall. After “GPS Test” is installed, tap the menu icon ( ) in the upper right corner then tap CLEAR AGPS. Tap the menu icon ( ) again, this time tap UPDATE AGPS.
A-GNSS works by providing the necessary data to the device via a radio network instead of the slow satellite link, essentially "warming up" the receiver for a fix. When applied to GPS, it is known as assisted GPS or augmented GPS (abbreviated generally as A-GPS and less commonly as aGPS).
The A-GPS data tells your Polar device the predicted positions of the GPS satellites. This way the Polar device knows where to search for the satellites and thus is able to acquire signals from them within seconds, even under difficult signal conditions. The A-GPS data updates once a day.
You should be able to use LocationManager.sendExtraCommand(String provider, String command, Bundle extras)
. This will allow you to delete all or part of the GPS data, so it will redownload it. The docs are here, but a quick rundown of the arguments, referenced from this code(for a GPS Provider):
For provider
, use LocationManager.GPS_PROVIDER
.
For command
, use "delete_aiding_data"
For extras, if you pass null
, it will delete all data. If you want to delete specific data only(such as just the almanac or position), you can use the flags found in this function as extras in the bundle.
Don't forget to add android.permission.ACCESS_LOCATION_EXTRA_COMMANDS
to your permission list in the manifest!
So far, the best answer to my question seems to be a combination of @Geobits' response and the XTRA injection code discussed in Problems with sendExtraCommand and force_xtra_injection. Based on this, I am currently using the following:
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
locationManager.sendExtraCommand(LocationManager.GPS_PROVIDER,"delete_aiding_data", null);
Bundle bundle = new Bundle();
locationManager.sendExtraCommand("gps", "force_xtra_injection", bundle);
locationManager.sendExtraCommand("gps", "force_time_injection", bundle);
If anyone has additional ideas on how to improve this, or how to determine the best times to clear and download new GPS data, I would be very interested to hear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With