1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question Setting phone’s time programatically

Discussion in 'Android Questions' started by rleiman, Jul 16, 2019.

  1. rleiman

    rleiman Well-Known Member Licensed 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: Jul 16, 2019
  2. ronell

    ronell Well-Known Member Licensed User

    on rooted device.. i guess

    search the forum , if i recall.. this topic has been discussed
     
  3. emexes

    emexes Well-Known Member Licensed User

    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?
     

    Attached Files:

  4. rleiman

    rleiman Well-Known Member Licensed 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
     
  5. emexes

    emexes Well-Known Member Licensed User

    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.
     
  6. emexes

    emexes Well-Known Member Licensed User

    Hey, I only just spotted that plane joke. Lol.
     
  7. ronell

    ronell Well-Known Member Licensed 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
     
  8. emexes

    emexes Well-Known Member Licensed User

    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: Jul 16, 2019
  9. emexes

    emexes Well-Known Member Licensed User

    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: Jul 16, 2019
  10. emexes

    emexes Well-Known Member Licensed User

  11. rleiman

    rleiman Well-Known Member Licensed User

    :p
     
  12. rleiman

    rleiman Well-Known Member Licensed User

    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.
     
  13. emexes

    emexes Well-Known Member Licensed User

    Really? Spewin :-/ I did see something about using the alarm clock service to set the time, but didn't read the detail. Let me check my browser history... never know your luck in the big city :)
     
  14. emexes

    emexes Well-Known Member Licensed User

  15. DonManfred

    DonManfred Expert Licensed User

  16. ronell

    ronell Well-Known Member Licensed User

     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice