Back to project page ssniper-andengine.
The source code is released under:
Apache License
If you think the Android project ssniper-andengine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cladophora.ssniper; //from www.ja v a 2s. c o m import android.app.Activity; import android.content.Context; import android.graphics.Point; import android.util.DisplayMetrics; import android.view.Display; /** * Created by secusr on 1/25/14. */ public class DeviceUtil { public static String getScreenType(Context mContext) { try { final int densityDpi = mContext.getResources().getDisplayMetrics().densityDpi; switch (densityDpi) { case DisplayMetrics.DENSITY_LOW: return "ldpi"; case DisplayMetrics.DENSITY_MEDIUM: return "mdpi"; case DisplayMetrics.DENSITY_TV: return "tv"; case DisplayMetrics.DENSITY_HIGH: return "hdpi"; case DisplayMetrics.DENSITY_XHIGH: return "xhdpi"; case DisplayMetrics.DENSITY_XXHIGH: return "xxhdpi"; default: return String.valueOf(densityDpi); } } catch (Throwable e) { return "unknown"; } } public static int getWidth(final Activity a) { final Display display = a.getWindowManager().getDefaultDisplay(); final Point size = new Point(); display.getSize(size); return size.x; } public static int getHeight(final Activity a) { final Display display = a.getWindowManager().getDefaultDisplay(); final Point size = new Point(); display.getSize(size); return size.y; } }