Android Question set time zone snippit

rworner

Member
Licensed User
Longtime User
Does anyone have a code snippet that they can share that shows how to set the time zone?

I am using a rooted Android mini PC connected to a TV as a kiosk. The app pulls data from a local server and displays real-time information based on that location. However the clock in the lower corner only matches if it was set to the same time zone that the server is in. I can get the time zone, time zone offset and DST indicator from the server and determine what I need to change the time zone to, however I have not been successful in getting it to change on the device and display the proper time on the system clock.

Any help would be greatly appreciated.
 

rworner

Member
Licensed User
Longtime User
Setting the time (or time zone) cannot be done on unrooted devices. I'm not sure that it can be done on rooted devices as well unless you are able to sign your app with the system key.


I was thinking that the system setting would be held in a database table somewhere - and that I could use sqlite to access the table and update the setting as an option. Would that be possible on a rooted device without knowing the system key?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Upvote 0

rworner

Member
Licensed User
Longtime User
Have a look here: http://stackoverflow.com/questions/12175647/change-timezone-in-android-device.

That post suggests that editing one or two text files can set the timezone on a rooted device.

Martin.

Thanks, but the post at the bottom says that it is for a unix device not Android. I am still trying different things and
am trying getprop/setprop.

With getprop I found:[persist.sys.timezone]: America/New_York
I tried to use setprop:
P.Shell("setprop","persist.sys.timezone","America/Chicago")

but got this error message:
Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1}
Occurred on line: 56
P.Shell("setprop","persist.sys.timezone","America/Chicago")
Word: persist.sys.timezone

Any suggestions?
 
Upvote 0

rworner

Member
Licensed User
Longtime User
Not that I'm familiar with.

I am still trying different things and am trying getprop/setprop.

With getprop I found:[persist.sys.timezone]: America/New_York
I tried to use setprop:
P.Shell("setprop","persist.sys.timezone","America/Chicago")

but got this error message:
Parsing code. 0.02
Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1}
Occurred on line: 56
P.Shell("setprop","persist.sys.timezone","America/Chicago")
Word: persist.sys.timezone

Any suggestions?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…