java - scheduled alarm to repeat every minute of the clock android -
i have app requires code executed every minute. issue code has executed @ every minute change of clock. means,
if 12:34 code execute @ 12:35 , goes on. current code works includes seconds. meaning,
if 12:34:30 , alarm starts, code executed. code executed @ 12:35:30.
i want code executed each minute according clock of phone. below current code.
intent intent2 = new intent(mainactivity.this, myabservice.class); pendingintent pintent = pendingintent.getservice(mainactivity.this, 0, intent2, 0); alarmmanager alarm_manager = (alarmmanager) getsystemservice(context.alarm_service); alarm_manager.setrepeating(alarmmanager.rtc, c.gettimeinmillis(), 1 * 1000, pintent);
im making execute every second effect takes place @ exact time. instead of having every second need repeat @ every minute change of clock (every minute)
how go this
use intent.action_time_tick broadcast intent fired every minute android os. register register normal system broadcast in code (doesn't work manifest)
tickreceiver=new broadcastreceiver(){ @override public void onreceive(context context, intent intent) { if(intent.getaction().compareto(intent.action_time_tick)==0) { //do } }; //register broadcast receiver receive time_tick registerreceiver(tickreceiver, new intentfilter(intent.action_time_tick));
this article describes complete process.
Comments
Post a Comment