What's the proper way to get DisplayMetrics, i.e. get screen/display info such as density or xdpi?
I ask because I've seen two ways of going about this:
FIRST:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
then getting the info by metrics.density or metrics.xdpi, etc
SECOND:
getResources().getDisplayMetrics().density
in this method I believe you can also just initialize a variable to hold the DisplayMetric and then grab info like in the FIRST method:
DisplayMetrics metricsMethodTwo = getResources().getDisplayMetrics()
and then you can get info like normal: metricsMethodTwo.density or metricsMethodTwo.xdpi
I've seen both in various places in the Docs. So what are the differences if any, and when is one method favored (or more appropriate) over the other and why? Thanks