Android examples for Hardware:Device Feature
get Device Size
//package com.java2s; import android.content.Context; import android.util.Log; import android.view.WindowManager; public class Main { private static final String TAG = "DeviceUtil"; public static int getDeviceSize(Context context, int code) { WindowManager manager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); int size; int width = manager.getDefaultDisplay().getWidth(); int height = manager.getDefaultDisplay().getHeight(); switch (code) { case 0:/* w ww .j av a 2 s .com*/ size = width; break; case 1: size = height; break; default: size = width; break; } Log.i(TAG, "Device size?Width:" + width + ",Height:" + height); return size; } }