سؤال

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?

هل كانت مفيدة؟

المحلول

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;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top