@Singleton public class KeepAlive extends Object
Modifier and Type | Method and Description |
---|---|
protected void |
decreaseCounter() |
protected int |
getCounter() |
void |
notifyAlarmStopped() |
void |
startKeepAlive()
Starts the keep-alive foreground service with default parameters,
message equal to "Waiting for an external action to finish"
and no timeout
|
void |
startKeepAlive(String message,
long timeout)
Starts the keep-alive foreground service
|
void |
stopKeepAlive(boolean shouldForce)
Stops the keep-alive foreground service.
|
@Inject public KeepAlive(Context context)
public void startKeepAlive()
public void startKeepAlive(String message, long timeout)
message
- The message to be displayed in the notificationtimeout
- Time in seconds after which the service will automatically stop.
If <=0, the service will never stop by itselfpublic void notifyAlarmStopped()
protected int getCounter()
protected void decreaseCounter()
public void stopKeepAlive(boolean shouldForce)
shouldForce
- Whether the service should be force stopped immediately