1

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?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Makar Emelyanov
  • 167
  • 5
  • 16

1 Answers1

2

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;
Andrey Starodubtsev
  • 5,139
  • 3
  • 32
  • 46