datetime - How schedule local notifications Android? -
i have question local notifications in android. developing application in first part must receive meetings of company of own server (this have achieved), , second part must notify 1 day before each meeting, local notifications.
how schedule local notifications @ given date?
to schedule local notification need know of things used schedule notification
broadcastreceivers intentfilters alarmmanager notificationservice pendingintent
in mainactivity following
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); alarmmanager alarmmanager = (alarmmanager) getsystemservice(context.alarm_service); intent notificationintent = new intent("android.media.action.display_notification"); notificationintent.addcategory("android.intent.category.default"); pendingintent broadcast = pendingintent.getbroadcast(this, 100, notificationintent, pendingintent.flag_update_current); calendar cal = calendar.getinstance(); cal.add(calendar.second, 15); alarmmanager.setexact(alarmmanager.rtc_wakeup, cal.gettimeinmillis(), broadcast); } the above code schedule alarm after 15 seconds. after 15 seconds broadcast notificationintent.
the action specified in intent constructor defined in androidmanifest.xml
to understand full working of local notification , see sample notification code check out article - http://www.singhajit.com/schedule-local-notification-in-android/
Comments
Post a Comment