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