public final class RemoteNotifications
extends java.lang.Object
updateNotificationsFromServer(UpdatePolicy)
. This will load the configured notifications and store it in the
libraries store. Call showPendingNotificationsToUser(boolean)
to automatically show notifications to the
user by an AlertDialog
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TAG |
Constructor and Description |
---|
RemoteNotifications(android.content.Context context,
java.net.URL serverUrl)
Constructs a new
RemoteNotifications . |
RemoteNotifications(android.content.Context context,
java.net.URL serverUrl,
java.lang.String sharedPreferenceName)
Constructs a new
RemoteNotifications . |
Modifier and Type | Method and Description |
---|---|
NotificationStore |
getPreferenceStore() |
void |
showPendingNotificationsToUser()
Shows all due notifications.
|
void |
showPendingNotificationsToUser(boolean showAll)
Shows due notifications.
|
static void |
start(android.content.Context context,
java.net.URL url,
UpdatePolicy updatePolicy)
Convenience method to update and show notifications.
|
void |
updateNotificationsFromServer(UpdatePolicy updatePolicy)
Starts an AsyncTask which loads the notifications from the server, removes local notifications which doesn't exist anymore and adds new
one.
|
void |
updateNotificationsFromServer(UpdatePolicy updatePolicy,
NotificationLoaderFinishListener listener)
Starts an AsyncTask which loads the notifications from the server, removes local notifications which doesn't exist anymore and adds new
one.
|
public static final java.lang.String TAG
public RemoteNotifications(android.content.Context context, java.net.URL serverUrl)
RemoteNotifications
. The Notifications from the server and the last server update timestamp will be
stored in a Shared Preferences file with the name . To change the name use
RemoteNotifications(Context, URL, String)
.context
- The application contextserverUrl
- The absolute URL to the notification JSON on a server (or file system), not null
.public RemoteNotifications(android.content.Context context, java.net.URL serverUrl, java.lang.String sharedPreferenceName)
RemoteNotifications
.context
- The application contextserverUrl
- The absolute URL to the notification JSON on a server (or file system), not null
.sharedPreferenceName
- The file name to use for the Shared Preferences file.public void showPendingNotificationsToUser()
showPendingNotificationsToUser(boolean)
public void showPendingNotificationsToUser(boolean showAll)
showAll
- if true
all pending notification dialogs will be shown (may result in bad user experience
if several dialogs are popping up). If false
only one dialog will be shown on each call
of this method.public void updateNotificationsFromServer(UpdatePolicy updatePolicy, NotificationLoaderFinishListener listener)
updatePolicy
- Use this parameter to reduce the number of server calls, not null
.listener
- a NotificationLoaderFinishListener
which is called after the update of the notifications finished.public void updateNotificationsFromServer(UpdatePolicy updatePolicy)
updatePolicy
- Use this parameter to reduce the number of server calls, not null
.public NotificationStore getPreferenceStore()
public static void start(android.content.Context context, java.net.URL url, UpdatePolicy updatePolicy)
context
- the application contexturl
- the URL of the JSON fileupdatePolicy
- the time between server updates