Android收起下拉通知栏

@bingoogolapple 2014-09-29 01:35:37发表于 bingoogolapple/bingoogolapple.github.io Android

     /**
     * 收起下拉通知栏。所需权限android.permission.EXPAND_STATUS_BAR
     * 
     * @param context
     */
    public static void collapseStatusBar(Context context) {
        try {
            Object statusBarManager = context.getSystemService("statusbar");
            Method collapse;
            if (Build.VERSION.SDK_INT <= 16) {
                collapse = statusBarManager.getClass().getMethod("collapse");
            } else {
                collapse = statusBarManager.getClass().getMethod("collapsePanels");
            }
            collapse.invoke(statusBarManager);
        } catch (Exception localException) {
            localException.printStackTrace();
        }
    }