Screen flickers when running on Android 4.2. (Activity gets restarted continuously)
Asked Answered
D

2

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?

Dayton answered 19/11, 2012 at 5:21 Comment(2)
This might be a silly question, but how do I open this window with CPU usage stats by methods?Athabaska
This is TraceView. developer.android.com/tools/debugging/debugging-tracing.htmlMisnomer
F
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
    ...
}
Filet answered 5/12, 2012 at 0:22 Comment(1)
it works, just one question, if i were to change the Configuration in other place beside 'onConfigurationChanged', do i still need to clone?Yockey
D
3

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

Dayton answered 20/3, 2013 at 14:59 Comment(1)
how did you find this issue?Alumnus

© 2022 - 2024 — McMap. All rights reserved.