0
Я хочу поднять уведомление, сравнивая текущую дату и время с датой и временем, хранящимся в SQLite db.yyyy-mm-dd hh -mm оба находятся в отдельной колонке.Как генерировать уведомление, сравнивая дату и время, хранящиеся в БД SQLite с текущей датой и временем
private void startAlarm() {
String[] dateArray=selectedDate.split("-");
int dat[]=new int[dateArray.length];
for(int i=0;i<dateArray.length;i++)
{
String d=dateArray[i];
dat[i]=Integer.parseInt(d);
}
AlarmManager alarmManager = (AlarmManager) this.getSystemService(this.ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.set(dat[2],dat[1],dat[0],selectedHour,selectedMinute);
public class ReminderService extends IntentService {
private static final int NOTIF_ID = 1;
public ReminderService(){
super("ReminderService");
}
@Override
protected void onHandleIntent(Intent intent) {
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
long when = System.currentTimeMillis();
System.out.println(when);
Notification notification = new Notification(R.drawable.alarm, "reminder", when);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags |= notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(this,MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent , 0);
notification.setLatestEventInfo(getApplicationContext(), "hiiiiiii","notification", contentIntent);
nm.notify(NOTIF_ID, notification);
}
}
System.out.println(""+dat[2]+""+dat[1]+""+dat[0]+""+selectedHour+""+selectedMinute+"##########################");
long when = calendar.getTimeInMillis();
System.out.println(when+"$$$$$$$$$$$$$$$$$$$$$$$$$$");
Intent intent = new Intent(this,ReminderService.class);
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0);
alarmManager.set(AlarmManager.RTC_WAKEUP, when, pendingIntent);
}
я сравнить все даты и времени в дб, если матч существует, то я поднимаю уведомление – Amar