最近太忙了。好长时间没动博客,把原来的东西拿出来都重新温习下。
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(); } }
android 状态栏操作
时间: 2024-10-14 03:32:19