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?
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); solves the problem.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With