Android examples for Hardware:Device Feature
Get device resolution that describe the pixels value of this display.
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.view.WindowManager; public class Main { /**//from w w w .j av a 2 s . c o m * Get device resolution that describe the pixels value of this display. * * @param context The context of the application. * @return The resolution with the with*height format. */ public static String getScreenResolution(Context context) { try { DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(displayMetrics); int width = displayMetrics.widthPixels; int height = displayMetrics.heightPixels; return "" + width + "*" + height; } catch (Exception e) { e.printStackTrace(); } return ""; } }