With security keyguard active transition between activities is weird

耗尽温柔 提交于 2019-12-22 10:45:15

问题


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


回答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.



来源:https://stackoverflow.com/questions/22731168/with-security-keyguard-active-transition-between-activities-is-weird

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!