3

I have my main activity A and when the user presses a button i open another activity B. But when this happens B doesn't just appear on top of A:

  • A disappears
  • secure keyguard shows up
  • B appears

And when i get rid of B the same thing happens. This is annoying because there's a lot of flickering with no real purpose on the screen. Is there any way to achieve direct transition from A to B while keyguard is active without merging the 2 activities into 1?

Here is what i'm doing in onCreate for both activities:

getWindow().addFlags(
        WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
                | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

And here is how i start the activity:

        final Intent intent = new Intent(Sand.this, EditRule.class);
        intent.putExtra(DB.KEY_PARENT_ID, id);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivityForResult(intent, 0);
        overridePendingTransition(0, 0);

I also tried setting a null android:windowAnimationStyle in the activity theme but no luck.

UPDATE: i submitted this bug: https://code.google.com/p/android/issues/detail?id=68465&thanks=68465&ts=1397301860

Thanks, Teo

Sandman
  • 2,577
  • 2
  • 21
  • 32
  • 1
    Same issue (http://stackoverflow.com/questions/22389765/lockscreen-is-displayed-between-activities) but no solution yet. I'll be interested to see if you find a solution. – Randy Apr 05 '14 at 20:59
  • I was beginning to think i'm the only one on the planet with this problem :) i'm actually looking for a solution for over a year now. I saw a really subtle effect with Intent.FLAG_ACTIVITY_NO_ANIMATION which in my tests makes the 'flicker' just a bit faster but doesn't eliminate it. If at the end of the bounty there's no solution i think i'll submit a bug. – Sandman Apr 05 '14 at 21:27
  • Just making sure I understand this, when you transition between Activity A and Activity B, your lock screen pops up, then closes, then your new activity pops up? – zgc7009 Apr 10 '14 at 20:51
  • Have you had the opportunity to look at this post? http://stackoverflow.com/questions/22389765/lockscreen-is-displayed-between-activities – zgc7009 Apr 10 '14 at 20:53
  • Yes that's what happens (and i saw that post, Randy linked to the same post in the first comment :) i tried everything in it, no luck. If there's really no solution i think it's safe to look at it as a bug because the focus is 'stolen' by the keyguard. The app doesn't lose focus if the keyguard is unlocked. IMHO maybe the way of setting WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED flags per activity is the problem. Until the activity has time to set these flags a part of it has already loaded without these flags... – Sandman Apr 11 '14 at 16:08
  • ... so the keyguard thinks it's ok to come in front. Maybe we should be able to set these flags on the whole application somehow. – Sandman Apr 11 '14 at 16:09

1 Answers1

1

I looked into this extensively (with a couple other engineers) a year or so ago on ICS and JB. It was not possible to avoid the flicker, which I strongly suspect is still the case in KitKat. You should file that bug.

(If you look at the Keyguard-related source in Android, it's a rather.. hefty mass of code/policy riddled with special cases. Since this case isn't explicitly documented anywhere, even if you can get it to work on one version, I would not rely on it working consistently.)

Ultimately, we worked around the issue by combining all of our must-not-flicker lockscreen UI into a single Activity. It was unpleasant, but it worked.

mik3y
  • 4,214
  • 1
  • 22
  • 29