The device density return 0 from some devices. The following code is used to calculate device density:
WindowManager wm = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
wm.getDefaultDisplay().getMetrics(metrics);
density = metrics.density;
This has resulted in some crashes in PlayStore. The users seem to be using: Galaxy Y Plus ; Android version 4.0.3 - 4.0.4. Also a device called wing-k70 had problems. In one crash it was version 4.2.
Please advice.
There is not much you can do other than handle this gracefully. If density is null or 0 check for it and use a default value in this case.
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