Question

There are boatloads of Android apps that set the time on a rooted Android from the GPS data. I even found one with malware in it, according to AVG. Grrr.

However, I'd like to build the capability into my application (which is always run on a rooted Android) and improve on some really poor user interfaces.

Does anyone know the procedure for getting the UTC time and using it to configure the Android hardware? Is it simply a matter of sudo-ing a set time command with the proper data??

Was it helpful?

Solution

for the GPS part is pretty straight forward:

You have to ask the LocationManager for a GPS fix, whenever you receive it you'll have a Location object.

Do some math with getElapsedRealtimeNanos() and getTime() on this location object to calculate the exact time.

as per the root part, not really necessary, but there's some nice amount of hack and work around on it: How to set mobile system time and date in android?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top