My application fires an intent twice, according to two set alarms, a start time and a stop time. I am now trying to expand on this so that the set alarms can be specified on multiple days, with the option of repeating.
I have 8 integer values received in a GCM on the target device, repeat = 1, sun = 1, mon = 1 etc ... if the day or repeat was selected, it has a value of 1.
How can I get the alarm to repeat on specific days ?
Can I put the received values, 0111110 would be all week days for example... then iterate through them and create the alarm where the value is a 1 ??
I am not sure how to structure this, could some one advise ?
Thanks.
Got it working, using the following ... maybe some one else will find this useful
int[] daysOfWeek = new int[7];
int[] daysOfWeekValue = new int[7];
//parce from GCM values recieved
final int sunday = Integer.parseInt(sun);
daysOfWeek[0] = sunday;
final int monday = Integer.parseInt(mon);
daysOfWeek[1] = monday;
final int tuesday = Integer.parseInt(tue);
daysOfWeek[2] = tuesday;
final int wednesday = Integer.parseInt(wed);
daysOfWeek[3] = wednesday;
final int thursday = Integer.parseInt(thu);
daysOfWeek[4] = thursday;
final int friday = Integer.parseInt(fri);
daysOfWeek[5] = friday;
final int saturday = Integer.parseInt(sat);
daysOfWeek[6] = saturday;
final int repeating = Integer.parseInt(repeat);
daysOfWeekValue[0]=1;
daysOfWeekValue[1]=2;
daysOfWeekValue[2]=3;
daysOfWeekValue[3]=4;
daysOfWeekValue[4]=5;
daysOfWeekValue[5]=6;
daysOfWeekValue[6]=7;
for (int i=0; i<daysOfWeek.length; i++)
{
if(daysOfWeek[i]==1){
Log.i(TAG, "Set alarm on day: " + daysOfWeekValue[i]);
final Calendar calNow = Calendar.getInstance();
final Calendar calSet = (Calendar) calNow.clone();
calSet.set(Calendar.DAY_OF_WEEK, daysOfWeekValue[i]);// 1 for sunday, 2 for monday etc
calSet.set(Calendar.HOUR_OF_DAY, starthour);
calSet.set(Calendar.MINUTE, startmin);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);
.....