I am trying to perform some task at certain intervals which has no definite frequency. Currently I am creating AlarmManager multiple times, is there any way to avoid creating muliple AlarmManager instances.
for(int i=0;i<a.gettotaldays(),i++){
AlarmManager am= (AlarmManager)
context.getSystemService(Context.ALARM_SERVICE);
am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), Constant.WEEKLY, pi);
}
getTotalDays() returns total times it should run, as per example below its 9(Task1: Mon, fri, Sat Task 2: Mon,Tue,Thu,Sunday)
For eg:- I want to perform some task on 11am on every Mon, Fri, Sat and again same task on 5 PM on every Mon, Tue, Thu and Sunday so and so forth(there can be any number of times the task should run).
There is no regular frequency as shown in example, I have to create one alarm for each each day, i.e task 1 I need to create 3 AlarmManager.setRepeating with frequency as Weekly. For task 2 I have to create 4 AlarmManager.setRepeating with frequency as Weekly.
0 comments:
Post a Comment