In my Application I am displaying some info to the users according to the user’s TimeZone.
I am allowing the users to select different cities in the world and to get the required info. By default I will get the TimeZone of the user from their Device using
`TimeZone myTZ = TimeZone.getDefault();`
And once the user changes the TimeZone , I am saving it in preferences. No problem in storing and retrieving the values from the preferences.
When another TimeZone is selected I set that TimeZone as default TimeZone using
`TimeZone.setDefault(TimeZone.getTimeZone("my_timezone"));`
when I print the TimeZone in the Log I am getting the TimeZone value as I set it. But when I use that TimeZone in my calculations I am getting previous TimeZone Value.
So I think the problem is the TimeZone is not changing , I want the user to set the selected TimeZone as their default TimeZone in their device. How shall I do this. What is the mistake I am doing?
Getting stuck in this for three days. Any suggestions to get out from this? Quick suggestion will helps me a lot. Thanks in Advance!!
As per documentation for
TimeZone.setDefault(...)–Apparently to change timezone through code you have to use AlarmManager. See the discussion here.
It requires this permission to be set in the manifest