what is a static wakelock?

android wakelock

Search for: android wakelock

Class documentation is here

Class lets you say that you need to have the device on. Call release when you are done and don't need the lock anymore


acquire
isHeld
Release

The parent class: PowerManager docs


PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); 

PowerManager.WakeLock wl = pm.newWakeLock
     (PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); 

wl.acquire();   

   //..screen will stay on during this section.. 

wl.release();

ACQUIRE_CAUSES_WAKEUP: Normally wake locks don't actually wake the device, they just cause it to remain on once it's already on.

FULL_WAKE_LOCK: Wake lock that ensures that the screen and keyboard are on at full brightness.

ON_AFTER_RELEASE: When this wake lock is released, poke the user activity timer so the screen stays on for a little longer.

PARTIAL_WAKE_LOCK: Wake lock that ensures that the CPU is running.

SCREEN_BRIGHT_WAKE_LOCK: Wake lock that ensures that the screen is on at full brightness; the keyboard backlight will be allowed to go off.

SCREEN_DIM_WAKE_LOCK: Wake lock that ensures that the screen is on (but may be dimmed); the keyboard backlight will be allowed to go off.

Choose the write constant. Looks like partial_wake_lock is a better choice if you care only about CPU being running.

Pay attention to when you acquire the wake lock as the system may have gone to sleep before acquiring it.

Try not use it as it can drain the battery