Base service class to handle background execution with an automatic mechanism of Android CPU wake locks. This class is for internal usage. More...
Public Member Functions | |
final int | onStartCommand (Intent intent, int flags, int id) |
abstract int | startService (Intent intent, int startId) |
IBinder | onBind (Intent i) |
Static Public Member Functions | |
static synchronized int | getNumOfHeldWakeLocks () |
Static Public Attributes | |
static final String | EXT_WAKE_ID = NAME + ".wakeLockId" |
static final int | ID_NULL = 0 |
static final int | WAKE_LOCK_TIMEOUT = 60*1000 |
Static Protected Member Functions | |
static void | addWakeLockId (Context ctx, Intent intent, Integer wakeLockId, boolean createIfNotExists) |
static void | addWakeLock (Context ctx, Intent i) |
static Integer | registerWakeLock (WakeLock wakeLock) |
static WakeLock | acquireWakeLock (Context ctx, String tag, long timeout) |
Base service class to handle background execution with an automatic mechanism of Android CPU wake locks. This class is for internal usage.
|
staticprotected |
Acquires a wake lock. ctx the android.content.Context
tag | the tag to supply to android.os.PowerManager |
timeout | the wake lock timeout |
|
staticprotected |
Adds a new wake lock to the specified intent. This will add the wake lock to the central wake lock registry managed by this class.
ctx | the android.content.Context |
i | the Intent to add the wake lock ID as extra to (never null) |
|
staticprotected |
Adds an existing wake lock identified by its registry ID to the specified intent.
intent | the android.content.Intent to add the wake lock ID as extra to (never null) |
wakeLockId | the wake lock registry ID of an existing wake lock or null |
createIfNotExists | if wakeLockId is null and this parameter is true true a new wake lock is created, registered, and added to intent |
|
static |
IBinder onBind | ( | Intent | i | ) |
final int onStartCommand | ( | Intent | intent, |
int | flags, | ||
int | id | ||
) |
|
staticprotected |
Registers a wake lock with the wake lock registry.
wakeLock | the android.os.PowerManager.WakeLock instance that should be registered with the wake lock registry (never null) |
|
abstract |
Subclasses need to implement this instead of overriding onStartCommand(Intent, int, int). This allows android.app.Service to manage the service lifecycle, including wake lock management.
intent | the Intent supplied to android.content.Context::startService(Intent) |
startId | a unique integer representing this specific request to start |
|
static |
|
static |
|
static |