Java tutorial
//package com.java2s; import android.content.Context; import java.lang.reflect.Field; public class Main { public static int getStatusBarHeight(Context context) { int statusBarHeight = 0; if (statusBarHeight == 0) { try { Class c = Class.forName("com.android.internal.R$dimen"); Object o = c.newInstance(); Field field = c.getField("status_bar_height"); int x = (Integer) field.get(o); statusBarHeight = context.getResources().getDimensionPixelSize(x); } catch (Exception e) { e.printStackTrace(); } } return statusBarHeight; } }