yuva ツ yuva ツ - 1 year ago 103
Android Question

Start Activity screen even if screen is locked in Android

How to start an Activity on device even if screen is locked. I tried as below but it's not working.

Broadcast receiver:

Intent alarmIntent = new Intent("android.intent.action.MAIN");
alarmIntent.setClass(context, Alarm.class);
alarmIntent.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED +
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD +
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON +

Yup Yup
Answer Source

You need the following permission in AndroidManifest.xml file:

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

Check the manifest details here. You can check this link on you query.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download