I want launch my activity on push notification over lock screen without change in lock.
Any special permission for that activity?
Update: If you want to show the Activity on the lock screen, you need to set showForAllUsers to true. Here's the description from the Android documentation: Specify that an Activity should be shown even if the current/foreground user is different from the user of the Activity. This will also force the android.
Here's how to open your favorite apps directly from the Lock screen on your Galaxy device: Go to Settings > Lock screen > Shortcuts. Tap Left shortcut and pick your desired app.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
{
setShowWhenLocked(true);
setTurnScreenOn(true);
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if(keyguardManager!=null)
keyguardManager.requestDismissKeyguard(this, null);
}
else
{
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
After API level 17 this would work
<activity
android:name=".yourActivityName"
android:showOnLockScreen="true"
android:screenOrientation="sensorPortrait" >
or write this in onCreate() before calling setContentView()
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With