0

I lock the device screen, start the activity LockAct. LockAct starts another activity which has a SurfaceView.

If I don't add <item name="android:windowBackground">@android:color/transparent</item> to the activity with the SurfaceView, neither surfaceCreated nor surfaceChanged will be called.

If I add <item name="android:windowBackground">@android:color/transparent</item> to the activity with the SurfaceView, LockAct disappears and slides in on Android 5.0 only as shown in the video. It looks ugly.

How to prevent LockAct from disappearing and sliding in again?

What I've already tried:

ActivityOptions for LockAct

Intent intent = new Intent(getApplicationContext(), LockAct.class);
startActivity(intent, ActivityOptions.makeCustomAnimation(getApplicationContext(), 0, 0).toBundle());

android:windowAnimationStyle for LockAct

<style name="NoAnim" parent="@style/AppTheme">
    <item name="android:windowAnimationStyle">@null</item>
</style>

<activity android:name="com.admin.LockAct"
    android:theme="@style/NoAnim" />

android:windowEnterTransition and android:windowExitTransition for LockAct

<style name="NoAnim" parent="@style/AppTheme">
    <item name="android:windowEnterTransition">@null</item>
    <item name="android:windowExitTransition">@null</item>
</style>

<activity android:name="com.admin.LockAct"
    android:theme="@style/NoAnim" />

Here is an archive with my sample Android app: https://www.dropbox.com/s/mc4pzqwc2o8lsej/Sample-Android-Lock.rar?dl=0

Maksim Dmitriev
  • 5,985
  • 12
  • 73
  • 138

1 Answers1

0

Activities are not started or finished smoothly when the device screen is locked. I noticed that on Android 5.0, but everything looks pretty good on my Samsung Galaxy S3 with CyanogenMod (Android 4.3.1). So different behavior may be on different devices and/or OS versions.

A co-worker gave me the link https://stackoverflow.com/a/23022023/1065835, and I'm going to use fragments instead of activities.

Community
  • 1
  • 1
Maksim Dmitriev
  • 5,985
  • 12
  • 73
  • 138