Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Lollipop Activity Screen corrupted [duplicate]

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

like image 835
Zenco Avatar asked Dec 01 '14 08:12

Zenco


3 Answers

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

like image 62
Surendra Kumar Avatar answered Oct 08 '22 02:10

Surendra Kumar


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.

like image 29
MineConsulting SRL Avatar answered Oct 08 '22 01:10

MineConsulting SRL


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.

like image 28
14 revs, 12 users 16% Avatar answered Oct 08 '22 02:10

14 revs, 12 users 16%