1

My application does have a custom notification which appears when the application is launched. The notification needs to have a button that opens a specific activity.

My problem occurs when the button is clicked by the user on the lockscreen. If the application was in background when the phone was locked, then the phone will unlock (by asking the password) and the activity will be launched. But if the application was in foreground when the phone was locked, then the phone will not unlock and I don't know why.

In my onCreate(), I put these parameters :

 Window window = this.getWindow();
 window.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD 
                | LayoutParams.FLAG_TURN_SCREEN_ON);
 }

and I launch the activity with :

Intent in = new Intent(context, MyActivity.class);
in.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(in);

Thank you for your help !

Luzgar
  • 11
  • 1
  • Is this the same https://stackoverflow.com/questions/44777437/how-to-open-application-while-clicking-notification – Abhi Jun 07 '18 at 10:45
  • Well not exactly. The password is asked and the application is opened only if the app was in background when the screen become locked :/ And this happen only Oreo/Nougat API. I tested it on Android 6.0 and it works normally. – Luzgar Jun 07 '18 at 13:38

0 Answers0