我想在活動中禁用狀態欄,我使用下面的代碼,它發生SecurityException, StatusBarManagerService:用戶10049或當前進程都沒有android.permission.STATUS_BAR。我添加了<uses-permission android:name="android.permission.STATUS_BAR">
,但它不工作?任何人都知道如何解決這個問題?由於如何在android中禁用狀態欄?
mStatusBar = getSystemService("statusbar");
if (mStatusBar != null){
Log.v("statusbar", "get status bar service "+mStatusBar.getClass());
Method[] arrayOfMethods;
Method localMethod;
arrayOfMethods = mStatusBar.getClass().getMethods();
for (int i = 0; i < arrayOfMethods.length; i++){
localMethod = arrayOfMethods[i];
Log.v("statusbar", "find status bar method "+localMethod);
if (localMethod.getName().equalsIgnoreCase("collapse")){
// mStatusBarCollapseMethod = localMethod;
} else if (localMethod.getName().equals("disable")){
try {
Log.v("statusbar", "invoke "+mStatusBar+"."+localMethod.getName()+"(1)");
localMethod.invoke(mStatusBar, 1);
Log.v("statusbar", "disable statusbar");
} catch (Exception e) {
Log.v("statusbar", "disable statusbar excption:"+e.toString());
e.printStackTrace();
}
}
}
}
}
回答了這裏:http://stackoverflow.com/a/10380535/788848 – PoOk 2012-06-12 09:03:03