[html] view plaincopyprint?
- public void onWindowFocusChanged(boolean hasFocus)
- {
- // TODO Auto-generated method stub
- System.out.println("hasfocus--->>>" + hasFocus);
- super.onWindowFocusChanged(hasFocus);
- try
- {
- Object service = getSystemService("statusbar");
- Class<?> statusbarManager =
- Class.forName("android.app.StatusBarManager");
- Method test = statusbarManager.getMethod("collapse");
- test.invoke(service);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
onWindowFocusChanged是重写Activity里面的方法,当执行这句话是表示activity加载完毕。
记得加权限:
[html] view plaincopyprint?
- <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
- <!-- <uses-permission android:name="android.permission.STATUS_BAR" /> -->
4.1模拟器测试有用,华为c8812测试有用,但是bug存在.........
时间: 2024-10-13 22:58:47