最近太忙了。好长时间没动博客,把原来的东西拿出来都重新温习下。
private void collapseStatusBar() { int currentApiVersion = android.os.Build.VERSION.SDK_INT; try { Object service = getSystemService("statusbar"); Class<?> statusbarManager = Class .forName("android.app.StatusBarManager"); Method collapse = null; if (service != null) { if (currentApiVersion <= 16) { collapse = statusbarManager.getMethod("collapse"); } else { collapse = statusbarManager.getMethod("collapsePanels"); } collapse.setAccessible(true); collapse.invoke(service); } } catch (Exception e) { e.printStackTrace(); } }