Question

My question is, what is the API for the sleep mode of a phone, if the phone is not used for a couple of minutes it goes into sleep mode right? Well what is the programming section on Android development is that?

Was it helpful?

Solution

Take a look on PowerManager and its inner class PowerManager.WakeLock. For example, to prevent some code from sleeping wrap it with

PowerManager pm = (PowerManager) SJPhone.getContext().getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(flags,WAKE_LOCK_STR);
wl.acquire();

// you code goes here

wl.release();
wl = null;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top