collapse Status Bar - Android android.app

Android examples for android.app:Status Bar

Description

collapse Status Bar

Demo Code

import java.lang.reflect.Method;

import android.content.Context;
import android.os.Build;

public class Main {

  public static final String STATUS_BAR_SERVICE = "statusbar";

  @SuppressWarnings("ResourceType")
  public static void collapseStatusBar(Context context) throws Exception {

    Object statusBarManager = context.getSystemService(STATUS_BAR_SERVICE);
    Method collapse;/* w w w. j av  a2 s.  c  om*/

    if (Build.VERSION.SDK_INT <= 16) {
      collapse = statusBarManager.getClass().getMethod("collapse");
    } else {
      collapse = statusBarManager.getClass().getMethod("collapsePanels");
    }
    collapse.invoke(statusBarManager);

  }

}

Related Tutorials