Reputation: 285
i want disable statusbar in activity, i have use below code, it happen SecurityException,
StatusBarManagerService: Neither user 10049 nor current process has android.permission.STATUS_BAR. I have add <uses-permission android:name="android.permission.STATUS_BAR">
, but it's not works? Anyone know how to resolve this problem? Thanks
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();
}
}
}
}
}
Upvotes: 2
Views: 7572
Reputation: 1896
IF you need to disable the status bar from your java code, then you can do this:
Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Upvotes: 4
Reputation: 6798
Simple solution, just add android:theme=”@android:style/Theme.NoTitleBar.Fullscreen”
to your manifest, for example:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.vogella.android.temperature"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Convert"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="9" />
</manifest>
Upvotes: 2