android - Alarmmanager - Fire alarm on top of every minute -


I'm trying to set an alarm fire every minute but for some reason it does not want to work. This is for a widget clock, which should be updated every minute. For battery reasons, I have stopped the receiver for the screen. So my alarm only occurs when the screen is on. Minutes should be syncron with my system clock. I

  public static void startClockTickAlarm () {AlarmManager alarmManager = (AlarmManager) _context.getSystemService (Context.ALARM_SERVICE); Calendar Calendar = Calendar.getInstance (); Calendar.setTimeInMillis (System.currentTimeMillis ()); Calendar.ed (calendar SECOND, 1); Calendar.ed (calendar.hora, 1); AlarmManager.Settering (alarm manager .rtc, UTCMilissenMinMin (), 60000, makeclockcontent (_context)); } Public stable last long utcMillisNextMin () {time t = new time (); T.setToNow (); T.second = 0; T.minute ++; System.out.println ("Next alarm:" + + t + + ":" + t.minute + ":" + t.second); Return t.normalize (true); }   

My system.out tells me exactly what this is. For example, I enable my widget at 11:30:15, returning result is 11:31:00 - that means my alarm should start at 11:31 first. According to my system clock, the alarm 5-15 seconds is too late seconds that the alarm goes out for a long time, it is not always the same (between 5 and 15 seconds).

Thank you in advance

as said, API & gt; = 19 If you should use the correct time, use the API

  if (android.os.Build.VERSION.SDK_INT & lt; 19) {alarmManager.setRepeating (AlarmManager.RTC, UtcMillisNextMin (), 60000, createClockTickIntent (_context)); } And {alarmManager.setExact (...); }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -