问题
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.setRepeating(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 .
回答1:
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);
回答2:
Maybe you can use another nonrepeating alarm for 20 or 30 days that stops repeating alarms.
来源:https://stackoverflow.com/questions/6591592/how-to-create-recurring-of-alarm-in-android-after-taking-user-input