Most of the Android developers that write applications for ICS should have noticed that it's impossible to run apps in full-screen. So how to remove the damned "status bar"? Let's check the code!
Policies needed to show/hide this bar are handled in this file:
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
Now let's search for "mStatusBarCanHide".
At a certain point there is an explicative comment that says:
// Determine whether the status bar can hide based on the size
// of the screen. We assume sizes > 600dp are tablets where we
// will use the system bar.
So it seems that the status bar in ICS can't be hidden only in devices that are considered "tablets".
I really don't care about modifying the calculations needed to check if a device is a tablet or no, so I made a really simple mod to switch back to the old fullscreen behaviour.
I added this flag:
boolean mStatusBarForceHide = true;
and then in the code I added a check for that flag:
if (topIsFullscreen) {
if (mStatusBarCanHide || mStatusBarForceHide ) {
if (DEBUG_LAYOUT) Log.v(TAG, "** HIDING status bar");
if (mStatusBar.hideLw(true)) {
changes |= FINISH_LAYOUT_REDO_LAYOUT;
mHandler.post(new Runnable() { public void run() {
if (mStatusBarService != null) {
try {
mStatusBarService.collapse();
} catch (RemoteException ex) {}
}
}});
}
} else if (DEBUG_LAYOUT) {
Log.v(TAG, "Preventing status bar from hiding by policy")
}
} else {
if (DEBUG_LAYOUT) Log.v(TAG, "** SHOWING status bar: top is not fullscreen");
if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT;
}
That's all!
Now the "android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" flag in your AndroidManifest.xml should work like a charm!
ciao ;)
RispondiEliminaNice finding. But how can I send that changes to the tablet? do I have to recompile the entire build/ROM? And assuming I don't have a custom ROM, how can I hide the status bar via this method.
Thanks in advance
Hi! :-)
EliminaYou need android full source code in order to recompile this part of framework. The resulting file will be android.policy.jar that needs to be placed in /system/framework/.
If you can't recompile your android source code then you can try using this method:
http://android.serverbox.ch/?p=306
Gian
RispondiEliminaI simply want to say I’m very new to blogs and actually loved you’re blog site. Almost certainly I’m going to bookmark your blog post . You absolutely come with great well written articles. Thanks a lot for sharing your blog.
Android Training in chennai | Android Training