public class ApplicationWatchdogManager
extends java.lang.Object
It allows you to initialize the application watchdog service for your application in order to shut it down in case of failure. It also allows to execute a pending intent after application is terminated.
Unless noted, all application watchdog API methods require the
com.digi.android.permission.WATCHDOG
permission. If your
application does not have this permission it will not be able to interact
with the application watchdog API.
SystemWatchdogManager
Modifier and Type | Field | Description |
---|---|---|
static long |
MINIMUM_WATCHDOG_TIMEOUT |
Minimum configurable timeout for the application watchdog service:
milliseconds.
|
Constructor | Description |
---|---|
ApplicationWatchdogManager(android.content.Context context) |
Class constructor.
|
Modifier and Type | Method | Description |
---|---|---|
long |
getTimeout() |
Returns the configured application watchdog service timeout for the
calling application.
|
void |
init(long timeout,
android.app.PendingIntent pendingIntent) |
Initializes the application watchdog service for the calling
application with the given timeout (in milliseconds).
|
boolean |
isRunning() |
Returns whether the application watchdog service has been initialized
for the calling application or not.
|
void |
refresh() |
Refreshes your application watchdog.
|
void |
stop() |
Stops the application watchdog service for the calling application.
|
public static final long MINIMUM_WATCHDOG_TIMEOUT
public ApplicationWatchdogManager(android.content.Context context)
ApplicationWatchdogManager
for the given application.
The ApplicationWatchdogManager
allows your application to
interact with the application watchdog service.
context
- Android application context for which the application
watchdog manager will be instantiated.java.lang.NullPointerException
- If context == null
.public void init(long timeout, android.app.PendingIntent pendingIntent)
This method registers the calling application to the application watchdog service in order to take specific actions on application failure. If the application fails to refresh the watchdog in the specified timeout, the application will be shut down and the given pending intent will be executed. This pending intent can be used to restart application when it fails.
Your application will be automatically removed from the application watchdog service once it is shut down due to failure. It is your responsibility to stop the application watchdog service on your application if it is manually terminated. The application watchdog service must be initialized again in your application once it is shut down and restarted.
You can remove your application from the application watchdog
service using the stop()
method.
timeout
- Watchdog timeout in milliseconds.pendingIntent
- Pending intent to execute when application is
shut down due to watchdog timeout. Can be
null
.java.lang.IllegalArgumentException
- If timeout
is not valid.java.lang.UnsupportedOperationException
- If the application watchdog
service has been already
initialized for the calling
application.MINIMUM_WATCHDOG_TIMEOUT
,
getTimeout()
,
isRunning()
,
refresh()
,
stop()
public long getTimeout()
This method can only be called once the application watchdog
service has been initialized for the calling application, otherwise
an UnsupportedOperationException
will be thrown.
java.lang.UnsupportedOperationException
- If the application watchdog
service has not been
initialized for the calling
application.init(long, PendingIntent)
,
isRunning()
,
refresh()
,
stop()
public boolean isRunning()
true
if the application watchdog service has been
initialized for the calling application, false
otherwise.init(long, PendingIntent)
,
getTimeout()
,
refresh()
,
stop()
public void stop()
Following this call, the application is no longer required to send refresh requests to the application watchdog service.
java.lang.UnsupportedOperationException
- If the application watchdog
service has not been
initialized for the calling
application.init(long, PendingIntent)
,
getTimeout()
,
isRunning()
,
refresh()
public void refresh()
java.lang.UnsupportedOperationException
- If the application watchdog
service has not been
initialized for the calling
application.init(long, PendingIntent)
,
getTimeout()
,
isRunning()
,
stop()