I have a database in which the user saves the things that he wants to do.In each thing he can set a date of expiration.the point is, I want to create a list(notification list) where the "things to do" that are going to expire will appear. for example the user wants to create a list with the things that are going to expire in two days. I have used the IntentService and pass with the intent the time that the user selects each time but i get nothing. do I have to use service or bound service in this case? thank you in advance
you can use AlarmManager class to fire off events at given times and in these events you can use NotificationManager to trigger the notifications.
See alarm manager example here: Alarm Manager Example
See notifications guide here: https://developer.android.com/guide/topics/ui/notifiers/notifications.html
Use the AlarmManager technique as like,..
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, yearFromDB);
calendar.set(Calendar.MONTH, monthFromDB);
calendar.set(Calendar.DAY_OF_MONTH, dateFromDB);
calendar.set(Calendar.HOUR_OF_DAY, hourFromDB);
calendar.set(Calendar.MINUTE, minuteFromDB);
calendar.set(Calendar.SECOND, 0);
Use PendingIntent for the Wake up at the Specific time and perform this Task..
alarmManager.set(AlarmManager.RTC_WAKEUP,calendar.getTimeInMillis(), ObjPendingIntent);
You can get the to do list on the Particular Time, Read on the PendingIntents and Alarmmanager by the following links..
http://developer.android.com/reference/android/app/PendingIntent.html
and
http://developer.android.com/reference/android/app/AlarmManager.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.