@Override public void onHandleIntent(Intent intent) { PowerManager.WakeLock wakeLock = LockUtil.getWakeLock(this); Log.i(LogUtil.TAG, "Started"); final String databaseName = intent.getStringExtra(DATABASE_NAME_KEY); if (databaseName == null) { Log.e(LogUtil.TAG, "Database name not specified."); return; } String action = intent.getAction(); if (action == null || action.equals(ACTION_RECORD)) { writeToDatabase(databaseName, intent); } else if (action.equals(ACTION_ARCHIVE)) { runArchive(databaseName); } wakeLock.release(); }
public static PowerManager.WakeLock getWakeLock(Context context) { return LockUtil.getWakeLock(context, context.getClass().getName()); }