9

I build my App with Android Lollipop SDK (21). After opening some activities and close they, one activity has this corrupted screen. It looks like a Memory error, but this happens only on Android Lollipop devices. In the Logcat i cant see errors.

Any ideas what this is?

enter image description here

Ajay S
  • 48,003
  • 27
  • 91
  • 111
Zenco
  • 2,963
  • 3
  • 17
  • 22
  • Do you have a `WebView` (or `AdView`) widget in your app, by chance? Did you check http://stackoverflow.com/questions/27172217/android-systemui-glitches ? – matiash Dec 10 '14 at 21:16
  • webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); solves the problem. – Surendra Kumar Dec 22 '14 at 11:26

3 Answers3

5

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); solves the problem.

Surendra Kumar
  • 2,787
  • 1
  • 12
  • 10
  • Thank you this worked for my app which uses WebView. I was experiencing the exact same corruption as pointed out by @Zenco. (I am using a Nexus 5 running Lollipop 5.0.1) Setting LayerType to TYPE SOFTWARE worked for me. :-) – Anthony De Souza Feb 04 '15 at 16:18
1

It should also happen on 4.4. Try to always assign a background to your fragment or activity. update Somebody did try using a transparent bkg and it didn't work.

MineConsulting SRL
  • 2,340
  • 2
  • 17
  • 32
1

The solution

webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

is OK, but a bit overkill since this issue only applies to Nexus devices on 5.0 Lollipop. Why punish all phone models?

boolean isLollipop = android.os.Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP;
boolean isNexus = android.os.Build.MODEL.toLowerCase().contains("nexus");

if (isLollipop && isNexus) {
    webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

This code assumes that Google will fix the problem in the next version of the OS.

Edit

As of 5.1 this has been fixed, which this code handles.

Martin Konecny
  • 57,827
  • 19
  • 139
  • 159