Here you can find the source of getStatusBarHeight(Activity activity)
public static int getStatusBarHeight(Activity activity)
//package com.java2s; import java.lang.reflect.Field; import android.app.Activity; public class Main { public static int getStatusBarHeight(Activity activity) { try {/*from ww w . j a v a2 s .c o m*/ Class<?> clazz = Class.forName("com.android.internal.R$dimen"); Object object = clazz.newInstance(); Field field = clazz.getField("status_bar_height"); int dpHeight = Integer.parseInt(field.get(object).toString()); return activity.getResources().getDimensionPixelSize(dpHeight); } catch (Exception e1) { e1.printStackTrace(); return 0; } } }