Android Question Setting phone’s time programatically

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Everyone,

I would like to set my phone’s system time based on the current location position. I’m planing on usine one of the B4A GPS libraries. Is it possible to do this programically? Is there a B4A library that will allow me to do it?

Truly,
Emad
 
Last edited:

emexes

Expert
Licensed User
I would like to set my phone’s system time
Just before you (and others) put too much effort in on this, perhaps check your phone's settings, because it should already be setting the time according to your network service provider anyway:

upload_2019-7-16_10-43-45.png


which will usually be the same time as "based on the current location position". Or are you doing some celestial calculations or similar?
 

Attachments

  • upload_2019-7-16_10-43-17.png
    upload_2019-7-16_10-43-17.png
    55.3 KB · Views: 200
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Hi everyone,

Thanks for the replies.

I’m planing on doing in flight going overseas so I won’t have access to any cell carriers.

Will the phone’s time be adjusted when crossing time zones by having location turned on?

Truly,
Emad
 
Upvote 0

emexes

Expert
Licensed User
I’m planing on doing in flight going overseas so I won’t have access to any cell carriers.

Will the phone’s time be adjusted when crossing time zones by having location turned on?
My experience with GSM has been that, upon arrival at an airport and turning off airplane/flight mode, the phone then spots the various networks, chooses one that it likes (strongest signal? affiliated with SIM service provider?) and updates the time accordingly. You do not need a SIM or account with the overseas cell carriers.

I have not done/tried this with NO SIM installed. I've read that emergency calls are still possible, so it is entirely possible that the time update will still work too.
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
if the mobile network don't work within the country then i think its a no, but if you connect to a wifi with gps on then google map will pinpoint your location :confused:
gmaps knows your location but not the time lol
 
Upvote 0

emexes

Expert
Licensed User
Will the phone’s time be adjusted when crossing time zones by having location turned on?
If the phone is in airplane mode, I would expect not. Mind you, GPS isn't going to work so well inside a big metal tube anyway. There's usually an onboard tv channel showing the plane on a global map, so you could always (shock, horror) manually update the phone's time zone as you cross the various lines.
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
gmaps knows your location but not the time
GPS signal includes time (always has, always will) that is more accurate than anything you're ever going to get outside of a standards laboratory, but you've got me wondering now: does Android use that info? Only problem I can see is that the time zone boundaries wiggle about a bit, so it would need a decent database to match geographic location to time zone correctly (cf defaulting to 15-degrees-wide hourly zones).

Like... who dreamed up this line?!?!
upload_2019-7-16_11-50-22.png
 
Last edited:
Upvote 0

rleiman

Well-Known Member
Licensed User
Longtime User
Bingo! No programming required :)

https://play.google.com/store/apps/details?id=net.sourcewalker.gpstime

This application helps you keep the internal clock of your Android device accurate by synchronizing it with the GPS time signal.

View attachment 82278

Nice app, but it does require root. I already made an app that requires the current time to match the time zone to give alerts to the user is in and would love to include this functionality as part of the app only if it didn't require the user to root their phone.
 
Upvote 0
Top