0

I'm developing an application which working on backround and in some particular event I have to show the activity even if the screen is locked.

So I tried to use flags instead of keyguard and wakelock, but I noticed that is only works when the screen is off without any password, pattern and etc... and when there is a password or something else, I see that the screen is turn on but the activity is dismissed...

Note: The activity theme is transparent because I only need to show the speech recognizer dialog...

This is the code I have to show the activity over the keyguard or when the screen is turned off

@Override
public void onAttachedToWindow()
{
    Log.d(TAG, "onAttachedToWindow");
    super.onAttachedToWindow();

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

So how can I dismiss the lock screen and show the activity?

Elior
  • 3,178
  • 6
  • 37
  • 67
  • What's your concrete question? I am not sure, if this is possible at all. Maybe you should use a notification? – Christopher Nov 20 '17 at 14:09
  • the above code is not working when the phone is locked using password or pattern.. and I want to dismiss the lock and show the activity anyway – Elior Nov 20 '17 at 14:11
  • You have to use an activity? I would recommend you to use WindowManager so it always will be above every screen/lock and etc.. – motis10 Nov 20 '17 at 14:14
  • Did you try `getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);` together with the code above? I've implemented like: https://github.com/BelledonneCommunications/linphone-android/blob/master/src/android/org/linphone/CallIncomingActivity.java#L77 and it's worked. – nhoxbypass Nov 20 '17 at 14:17
  • @motis10 Inside the activity I'm using speech recognizer intent.. and waiting for the results which I get in onActivityResult.. – Elior Nov 20 '17 at 14:17
  • @nhoxbypass does it even dismiss the pattern and password lock and show the activity? – Elior Nov 20 '17 at 14:18
  • @Elior yes. whenever you start this activity, it's go up over even the passlock – nhoxbypass Nov 20 '17 at 14:19
  • @nhoxbypass thanks, I will try it – Elior Nov 20 '17 at 14:19
  • @Elior but you can still wait to the intent by any solution and update the specific windowmanager layout according to the changes. – motis10 Nov 20 '17 at 14:21
  • @Elior did it work? Which device you are running? – nhoxbypass Nov 20 '17 at 14:49
  • @nhoxbypass , I'm using Nexus 6p with Android 7.1. it doesn't work as I expected.. it also open turn the screen on but the pattern lock dismiss the activity – Elior Nov 20 '17 at 15:22

0 Answers0