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?

Était-ce utile?

La 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;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top