Proper way to 100% wakes my device?

Posted by quiel on Stack Overflow See other posts from Stack Overflow or by quiel
Published on 2012-03-26T05:25:42Z Indexed on 2012/03/26 5:29 UTC
Read the original article Hit count: 136

Filed under:
|

Do you have better way to make the device awakes by 100%? I repeatedly call the acquire() but I'm not sure if that is correct. Or should I just call the acquire() once? Or should I make use of Intent.ACTION_SCREEN_OFF?

public class MyServiceThatKeepsTheDeviceAwake extends IntentService {   
...
@Override
public void onCreate() {
    super.onCreate();
    mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = mPowerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK |PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.ON_AFTER_RELEASE, TAG);
}

@Override
public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);
    mWakeLock.acquire();
}

// No release

© Stack Overflow or respective owner

Related posts about android

Related posts about wakelock