Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 30th, 2012  |  syntax: None  |  size: 0.40 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Class<?> c = null;
  2. Object obj = null;
  3. Field field = null;
  4. int x = 0, sbar = 0;
  5. try {
  6.     c = Class.forName("com.android.internal.R$dimen");
  7.     obj = c.newInstance();
  8.     field = c.getField("status_bar_height");
  9.     x = Integer.parseInt(field.get(obj).toString());
  10.     sbar = getResources().getDimensionPixelSize(x);
  11. } catch (Exception e1) {
  12.     loge("get status bar height fail");
  13.     e1.printStackTrace();
  14. }