我收到了我的应用程序的第一份崩溃报告。它说有一个java.lang.ArithmeticException: divide by zero
例外是在这两行之一:
//sWP stands for "Screen Width in Pixels"
// sW stands for "Screen Width" The code is old though, so I may be incorrect for both variables.
//res is just getResources()
int sWP = sW / (res.getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
float bHeight = 50 * ((float)res.getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT);
可以DisplayMetrics.DENSITY_DEFAULT
为零吗?或者getDisplayMetrics().densityDpi
永远为零?