android - TIMEZONE_CHANGED intent being received every few seconds -
i use broadcastreceiver timezone_changed action reset alarms using alarmmanager make sure alarm runs @ set time, not few hours earlier or later, depending on time zone change.
however in latest log sent user, saw information intent timezone_changed action being received every few seconds user complaining app being glitchy.
here's broadcastreceiver's onreceive code
@override public void onreceive(context context, intent intent) { utils.log("ontimechange"); string action = intent.getaction(); if (action.equals(intent.action_time_changed)) { utils.log("timechange"); } else if (action.equals(intent.action_timezone_changed)) { utils.log("timezonechanged"); } broadcastsmanager.updatebroadcastsfromalarms(context, alarmsdbadapter.getinstance(context)); }
the manifest's intent filter:
<intent-filter> <action android:name="android.intent.action.timezone_changed" /> <action android:name="android.intent.action.time_set" /> </intent-filter>
and part of log (it goes on hour - full lenght of log)
1. 19/4 7:41:54 - posting alarm 3 8:15 (in 0h) 2. 19/4 7:44:29 - ontimechange 3. 19/4 7:44:29 - timezonechanged 4. 19/4 7:44:29 - posting alarm 3 8:15 (in 0h) 5. 19/4 7:44:54 - ontimechange 6. 19/4 7:44:54 - timechange 7. 19/4 7:44:54 - posting alarm 3 8:15 (in 0h)
it's samsung galaxy s iii (android v 4.1.2). strange thing is, doesn't happen on s iii. user has set "automatic timezone change provider" option enabled on his/her device , information sent every few seconds?
has expierienced it? guess add option check if timezone has changed before updating broadcasts, still getting receiver called every few seconds...
i still don't know why timezone change , time set called often, able work out solution, lets me find out when reaction needed.
also listening timezone changes now.
sharedpreferences prefs = preferencemanager.getdefaultsharedpreferences(context); string oldtimezone = prefs.getstring(pref_timezone, null); string newtimezone = timezone.getdefault().getid(); long = system.currenttimemillis(); if (oldtimezone == null || timezone.gettimezone(oldtimezone).getoffset(now) != timezone.gettimezone(newtimezone).getoffset(now)) { prefs.edit().putstring(pref_timezone, newtimezone).commit(); logger.log("timezone time change"); //update alarms }
i added zone's time check, because found out, althought zones change, not differ in time in way. users claimed didn't travel anywhere far when numerous changes in zones detected - regular trips work , back.
check limited number of unneeded operations.
Comments
Post a Comment