Android provides a permission called "SET_TIME_ZONE" with OS permission level "dangerous". Does anyone know that given an application with this permission, how can the app set the time zone ?
Thanks.
If your objective is to change the system's default time zone, then use setTimeZone() of AlarmManager.
You can set the TimeZone in multiple ways:
You can use TimeZone.setDefault() which will change the TimeZone for the current process only. But as noted in the docs, this is not garanteed to last for the whole application lifecycle.
You can use setTimeZone() of AlarmManager to change the TimeZone of the whole device. But you need the "SET_TIME_ZONE"-permission for that.
If you think 1. is to dangerous and you don't have the permission for 2. your best approach is to get every Date from Calendar and set the TimeZone on your Calendar-instance via setTimeZone().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With