I developed my app using Mono for Android. I have the latest version 4.0.3. My AndroidManifest.xml specifies:
<uses-sdk android:targetSdkVersion="11" android:minSdkVersion="8" />
The app runs on tablets, so in Honeycomb I need to hide the status bar at the bottom of the screen. This is how I do that (with a simple extension method):
internal static void LightsOut(this View view)
{
try
{
IntPtr view_setSystemUiVisibility = JNIEnv.GetMethodID(view.Class.Handle, "setSystemUiVisibility", "(I)V");
JNIEnv.CallVoidMethod(view.Handle, view_setSystemUiVisibility, new JValue(1));
}
catch
{ }
}
I call this on every view that I instantiate. On my Motorola Xoom, running 3.0.1, this works great.
On my Samsung Galaxy Tab running 3.1, it works; but the status bar comes back after some short period of time. In the Android Log I see that LightsOn() is getting called…
How can I prevent the status bar from coming back in 3.1? I saw this event:
http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html
And thought I could use it to hide the status bar, if it comes back. But I don’t see how I can subscribe to it (it doesn’t show in Intellisense).
Does something specific happen before the status bar comes back, or is it solely time related? A quick search of the ICS source suggests that the status bar status will be reset when the top App Window changes. Are you calling
StartActivity()or moving to another app when you see this behavior?The
View.OnSystemUiVisibilityChangeListenerinterface has been bound as the View.IOnSystemUiVisibilityChangeListener interface and through the View.SystemUiVisibilityChange event. However, both of these mechanisms require that your$(TargetFrameworkVersion)target Android v3.1 or later, which would set your//uses-sdk/@android:minSdkVersionattribute to12, and is thus something you (presumably) don’t want to do.I see two plausible solutions here:
LightsOn()is being invoked and try to work around it (callLightsOut()within everyActivity.OnCreate()method?).minSdkVersionof8, and one of (at least)12, and then use Multiple APK Support to include both in your program. The device will then run the appropriate package, permitting access to theView.SystemUiVisibilityChangeevent.