I have implemented the push notification using GCM and when i receive the notification i want to show in a dialog for which i have created a custom dialog.
Now, i want my dialog to appear even if the device is locked whether a pattern match or PIN.
I have made following tries, but no positive result.
public void onAttachedToWindow() {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
and also
public void onAttachedToWindow() {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
+ WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
}
permissions in manifest:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
and also added the
android:showOnLockScreen="true"
for the activity to which i want to be shown when screen is locked.
Please help.