umesh umesh - 5 months ago 14
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);
pm.isDeviceIdleMode();


please help me to find out this problem.

Answer

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

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

Update

Add this permission in your manifest.xml

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