Java tutorial
//package com.java2s; import android.content.Context; import android.text.TextUtils; import android.util.DisplayMetrics; public class Main { public static String resolution = ""; public static String getResolution(Context context) { if (TextUtils.isEmpty(resolution)) { DisplayMetrics displaymetrics = context.getResources().getDisplayMetrics(); if (displaymetrics.widthPixels == 720) { resolution = "hd720"; } else if (displaymetrics.widthPixels == 1080) { resolution = "hd1080"; } else if (displaymetrics.widthPixels == 1440) { resolution = "hd1440"; } else if (displaymetrics.widthPixels == 2160) { resolution = "hd2160"; } else { return displaymetrics.widthPixels + "x" + displaymetrics.heightPixels; } } return resolution; } }