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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -