Reputation: 984
I need to create an android app containing an webview in my activity. The webview activity has to shown in full screen without showing the title bar. So I have given like this in my manifest:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
also in my mainactivity.class. I have given like this before the setcontentview:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
Also in my main activity I have given like this:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Now I want this app to be developed for all versions of android starting from 2.3 Gingerbread. Now the problem comes. When I run this on 2.3.6 Gingerbread, the app works fine in full screen. Where as when I try to run it on version 4.3 Jelly Bean, the app force closes. What is the problem behind this? How to make this app support on all versions of android?
I have searched many times in stackoverflow, but did't find a solution to my problem. That's why I ask it as a question. Any help from anyone is easily appreciated...
Thanks in advance
Upvotes: 0
Views: 1118
Reputation: 653
try the following code.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
else{
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
Hope this helps!
Upvotes: 2