android禁止狀態欄下拉

[html] view plaincopyprint?html

  1. public void onWindowFocusChanged(boolean hasFocus)  android

  2.     {  app

  3.         // TODO Auto-generated method stub  測試

  4.         System.out.println("hasfocus--->>>" + hasFocus);  spa

  5.         super.onWindowFocusChanged(hasFocus);  .net

  6.         try  orm

  7.         {  htm

  8.             Object service = getSystemService("statusbar");  blog

  9.             Class<?> statusbarManager =  get

  10.                     Class.forName("android.app.StatusBarManager");  

  11.             Method test = statusbarManager.getMethod("collapse");  

  12.             test.invoke(service);  

  13.         }  

  14.         catch (Exception ex)  

  15.         {  

  16.             ex.printStackTrace();  

  17.         }  

  18.     }  

onWindowFocusChanged是重寫Activity裏面的方法,當執行這句話是表示activity加載完畢。

記得加權限:

[html] view plaincopyprint?

  1. <uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />  

  2.      <!-- <uses-permission android:name="android.permission.STATUS_BAR" /> -->  


4.1模擬器測試有用,華爲c8812測試有用,可是bug存在.........

相關文章
相關標籤/搜索