umesh umesh - 1 year ago 132
Android Question

How To Get Application In Sleep Mode

How to do hold application get in sleep mode android programmatically.

I used this function but it gave me crash.

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

please help me to find out this problem.

Answer Source

I think that's what are you looking for Power Manager.

Add this <permission android:name="android.permission.DEVICE_POWER"/> in your manifest too.


Add this permission in your manifest.xml

<uses-permission android:name="android.permission.WAKE_LOCK" />