I have app that will get the time and date values from database and it should be given to alarm to generate notification...but I am stuck how to get values of date and time from database and give to alarm manager for getting notifications...I am having many times and dates in database...I have to fetch time and date and give it to alarm manager to generate notification...so far I have tried the code its only generating for a single day only...when I am giving new alarm the old ones are getting deleted...only last set alarm time is given to alarm manger and its giving notification only to the last one set...please help me out guys...`
Calendar ca = Calendar.getInstance();
ca.setTimeInMillis(System.currentTimeMillis());
int hr = ca.get(Calendar.HOUR)*60*60*1000;
int hr1 = ca.get(Calendar.MINUTE)*60*1000;
int hr2 = ca.get(Calendar.SECOND)*1000;
int cal = hr + hr1;
for(int y=1;y<h.length;y++){
Toast.makeText(getApplicationContext(), "" +h[y],3000).show();
String q[]=h[y].split(":");
Integer i=Integer.parseInt(q[0]) * 60 * 60 * 1000;
Integer i2=Integer.parseInt(q[1]) * 60 * 1000;
long set= i + i2;
long interval= set - cal;
Toast.makeText(getApplicationContext(), "" +interval,3000).show();
intr.add(interval);
y++;
}
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
ArrayList<PendingIntent> intentArray = new ArrayList<PendingIntent>();
for(int i = 0; i < intr.size(); ++i){
Intent intentAlarm = new Intent(getApplicationContext(),AlarmReciever.class);
PendingIntent p=PendingIntent.getBroadcast(getApplicationContext(), i, intentAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.set(AlarmManager.RTC_WAKEUP, ca.getTimeInMillis()+intr.get(i), p);
//...
}
Till now i am calculating the difference time between current time and stored time and giving to alarm manger for getting notifications...but i need all the values that stored in database according to the time and date..