java.lang.Object | |
↳ | com.neomades.notification.NotificationManager |
Local Notification manager.
The local notification manager must be used to show, schedule or cancel local
Notification
.
NB. In this section we will not talk about the graphical aspect of the
notification, this can be done vie the Notification
class.
There are several way to display a notification:
notify(Notification)
or
showNotification(Notification)
.schedule(Notification, int)
.schedule(Notification, Calendar)
.
When a notification is triggered while the application is in background, it
will be displayed to the user. The UI of notification depends of its type. If
the application is in foreground when the notification is triggered, nothing
visual to the end user will be displayed. However, work can be done on the
received notification by overloading
onLocalNotificationReceived(Notification)
. This will
enable to display a dialog with the notification data for example.
To use local notifications, the LOCAL_NOTIFICATION
permission
should be declared in the URS project file
.
<urs> <permissions> <permission name="LOCAL_NOTIFICATION"/> <permissions/> <urs/>
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | INTERVAL_DAY | Scheduled notification interval: notify every day. | |||||||||
int | INTERVAL_HALF_DAY | Scheduled notification interval: notify every 12 hours. | |||||||||
int | INTERVAL_HALF_HOUR | Scheduled notification interval: notify every 30 minutes. | |||||||||
int | INTERVAL_HOUR | Scheduled notification interval: notify every 60 minutes. | |||||||||
int | INTERVAL_MINUTE | Scheduled notification interval: notify every minute. | |||||||||
int | INTERVAL_MONTH | Scheduled notification interval: notify every month. | |||||||||
int | INTERVAL_WEEK | Scheduled notification interval: notify every week. | |||||||||
int | INTERVAL_YEAR | Scheduled notification interval: notify every year. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
cancel(Notification notification)
Cancels a pending notification.
| ||||||||||
void |
cancelAll()
Cancels all pending notifications.
| ||||||||||
Notification |
findNotificationByExtra(String extra)
Finds a scheduled locale notification by extra value.
| ||||||||||
Notification |
findNotificationById(int id)
Finds a scheduled locale notification by identifier.
| ||||||||||
static NotificationManager |
getDefault()
Gets the default notification manager.
| ||||||||||
Vector<Notification> |
getScheduledNotifications()
Returns the list of all the registered scheduled notifications.
| ||||||||||
void |
notify(Notification notification)
Notifies immediately the end-user with a
Notification . | ||||||||||
void |
schedule(Notification notification, Calendar date)
Schedules a
Notification at one date. | ||||||||||
void |
schedule(Notification notification, int interval)
Schedules a
Notification periodically. | ||||||||||
void |
showNotification(Notification notification)
Shows the
Notification in the status bar no matter if the application
is in background or in foreground. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Scheduled notification interval: notify every day.
Scheduled notification interval: notify every 12 hours.
Scheduled notification interval: notify every 30 minutes.
Scheduled notification interval: notify every 60 minutes.
Scheduled notification interval: notify every minute.
Scheduled notification interval: notify every month.
Scheduled notification interval: notify every week.
Scheduled notification interval: notify every year.
Cancels a pending notification.
notification | the notification to cancel. |
---|
NullPointerException | if the parameter is null |
---|
Cancels all pending notifications.
Finds a scheduled locale notification by extra value.
extra | extra value contained by notification |
---|
Finds a scheduled locale notification by identifier.
id | the notification identifier |
---|
Gets the default notification manager.
Returns the list of all the registered scheduled notifications. Notifications that must be scheduled only once at a specific date will be returned too. Cancelled notifications will not appear in this list.
Notifies immediately the end-user with a Notification
.
If the application is in foreground the method:
onLocalNotificationReceived
is directly called while if the application is
in background the Notification
is shown in the status bar.
notification | the notification to show |
---|
NullPointerException | if the notification is null |
---|
Schedules a Notification
at one date.
Warning: If the application is in foreground state (visible to the
end-user), then the notification will not be displayed at the status bar,
only the callback method
onLocalNotificationReceived
will be called.
NB. the trigger of the notification is not very accurate and can vary from some seconds to around one hour on some platforms.
notification | the notification to schedule. |
---|---|
date | a date in the future |
NullPointerException | if a parameter is null |
---|
Schedules a Notification
periodically.
Warning: If the application is in foreground state (visible to the
end-user), then the notification will not be displayed at the status bar,
only the callback method
onLocalNotificationReceived
will be called.
NB. the time interval between notification trigger is not very accurate and can vary from some seconds to around several minutes on some platforms.
notification | the notification to schedule |
---|---|
interval | time interval in minutes |
NullPointerException | if a parameter is null |
---|
Shows the Notification
in the status bar no matter if the application
is in background or in foreground.
notify(Notification)
.
notification | the notification to show |
---|
NullPointerException | if the parameter is null |
---|