The screen flickers when running on Android 4.2. (Activity restarts continuously)

Some users reported that the screen of my application sometimes flickers when running on Android 4.2 (only!)

I tried on my device, and after entering the logs, the activity restarts and restarts again, about 3 times per second.

So, I did to track method calls when it restarts constantly, and here is the result:

method trace output

It seems that the problem is with ViewGroup.resetRtlProperties () as it is new in Android 4.2 (17).

I still can not confirm if this is a mistake, but does anyone else have this or any workarounds?

+6
source share
2 answers

I had a similar problem and this was caused by a combination of the following two:

  • Activity in landscape orientation (while the preferred portrait of the device)
  • Code in onConfigurationChanged () of the Application subclass that changed the locale of the newConfig parameter

Instead of changing newConfig, you can clone this object and modify / use the clone:

@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); Configuration configClone = new Configuration(newConfig); // Change/use configClone here ... } 
+7
source

Apparently, adding layoutDirection to the android:configChanges your <activity> in AndroidManifest.xml fixes this problem.

+2
source

All Articles