6

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

I tried on my device, and after putting logs, the activity is restarted and restarted again, about 3 times a second.

So what I did is to trace the method calls when it restarts continually, and here is the result:

method trace output

It seems that the problem lies in the ViewGroup.resetRtlProperties(), since this is new in Android 4.2 (17).

I can't confirm yet if this is a bug, but is there anyone else experiencing this or have any workarounds?

j0k
  • 22,600
  • 28
  • 79
  • 90
Randy Sugianto 'Yuku'
  • 71,383
  • 57
  • 178
  • 228

2 Answers2

7

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

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

Instead of changing newConfig you can clone that object and change/use the clone:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Configuration configClone = new Configuration(newConfig);
    // Change/use configClone here
    ...
}
Adam Nybäck
  • 845
  • 7
  • 13
3

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

Randy Sugianto 'Yuku'
  • 71,383
  • 57
  • 178
  • 228