Skip to content Skip to sidebar Skip to footer

How To Notify A User With Sms Or Notification When Needed

So in my app I'm looking to have the students class schedules and the times which they need to be in class. When the app is turned off I still want the notification to pop up that

Solution 1:

You need a Service which can run when the app is not opened. You should also think about a BroadcastReceiver that listens to BOOT_COMPLETED

Solution 2:

You will need to use the AlarmManager to set an alarm when you require the notification, possibly with the RTC_WAKEUP flag so the device will wake from a sleep. From your alarm receiver you will need to take a wake lock (if you used RTC_WAKEUP) and start a service that will use the NotificationManager to display a message to the user (very similar to the incoming SMS message).

As @WarrenFaith pointed out you will need to create a BOOT_COMPLETED receiver to re-establish the alarm after the phone is rebooted as they are not persistent.

Post a Comment for "How To Notify A User With Sms Or Notification When Needed"