I am an android developer.I am making an application in which I have to take user input like 8:00,9:00,10:00 etc and I have to set alarm for 20 or 30 days for each time user enter .A user can enter two or three or any times the timings.I know there is a function
alarm.setRep开发者_如何学Goeating(AlarmManager.RTC,System.currentTimeMillis()+timeinminutes*60*1000,30*1000, pintent);
But I have to set the alarm for ever or days entered by user .So can any body tell me .How can I do this .
the following code help you,firstWake the app will run at very fast time,you can specify as your requirements
AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
long interval = android.text.format.DateUtils.DAY_IN_MILLIS*20;//or 30
long firstWake = System.currentTimeMillis() ;
am.setRepeating(AlarmManager.RTC,firstWake, interval, pendingIntent);
Maybe you can use another nonrepeating alarm for 20 or 30 days that stops repeating alarms.
精彩评论