I created a launcher, to use it in an internal application. for some security reasons i would like to hide the system bar (the acces to the parameter an ordrer to the acces to installed application). But i have no idea how to do this.
Tablet that will be used are not rooted.
Can you help me please?
You can't hide it but you can disable it, except home. For that you can give your application as home category and let the user choose.
<category android:name="android.intent.category.HOME" />
Rest all can be disable.
add this in manifest.
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"/>
inside onCreate()
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_home);
View v = findViewById(R.id.home_view);
v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
where home_view is the parent view of xml file.
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}
public void onWindowFocusChanged(boolean hasFocus)
{
try
{
if(!hasFocus)
{
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
Method collapse = statusbarManager.getMethod("collapse");
collapse .setAccessible(true);
collapse .invoke(service);
}
}
catch(Exception ex)
{
}
}
You can hide the bottom bar I used this code to hide:
getWindow().getDecorView().setSystemUiVisibility(View.GONE);
use this code for android box with keyboard or remote.
Tablet that will be used are not rooted
Then you can't hide it. You can however use SYSTEM_UI_FLAG_HIDE_NAVIGATION to hide it temporary, but it will get visible once the user touches the screen:
There is a limitation: because navigation controls are so important,
the least user interaction will cause them to reappear immediately.
When this happens, both this flag and SYSTEM_UI_FLAG_FULLSCREEN will
be cleared automatically, so that both elements reappear at the same
time.
You can hide the navigation bar on Android 4.0 and higher using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions
See the following: Hiding the Navigation Bar
Put this in your onCreate() method:
requestWindowFeature(Window.FEATURE_NO_TITLE);
EDIT: Hiding the status bar would require your application be full screen or rooted.
Related
I have an Android Application that is made using Fragments
I am hiding the bars at top and bottom of my screen, using the following code.
#Override
protected void onResume() {
super.onResume();
isInBackground = false;
if(null == getFragmentManager().findFragmentById(R.id.content_container))
{
getFragmentManager().beginTransaction().add(R.id.content_container,new PresenterFragment(), PresenterFragment.FRAG_TAG).commit();
}
if(Build.VERSION.SDK_INT >=19)
{
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
#Override
public void onSystemUiVisibilityChange(int visibility) {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
});
}
}
When the soft keyboard it shown the bars show, I can live with this as they hide when the keyboard is dismissed.However if a dialog Fragment is show while the soft keyboard is shown then when both the keyboard and the dialog fragment are dismissed they bars remain over the top of the application.
My 3 questions are
Is it possible to stop the softkeyboard for changing the UI mode?
Is it possible to stop the showing of DialogsFraments from changing the UI mode?
edit: I used to below code to see if the keyboard is shown
public static boolean isKeyBoardShown(){
InputMethodManager imm = (InputMethodManager)currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isAcceptingText()) {
return true;
} else {
return false;
}
}
-> I know that there is a work around for dialogs in an activity but I can't see one or rework the code to work in a DialogFragment
If neither is possible why does the app get stuck in the wrong UI mode when there is both a shown keyboard and DialogFrament?
1. Explanation for solution.
I have taken the following quotes from the android api docs.
Using Immersive Full-Screen Mode
When immersive full-screen mode is enabled, your activity continues to
receive all touch events. The user can reveal the system bars with an
inward swipe along the region where the system bars normally appear.
This clears the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag (and the
SYSTEM_UI_FLAG_FULLSCREEN flag, if applied) so the system bars become
visible. This also triggers your
View.OnSystemUiVisibilityChangeListener, if set.
Firstly, you don't need an OnSystemUiVisibilityChangeListener when using sticky immersion.
However, if you'd like the system bars to automatically hide again
after a few moments, you can instead use the
SYSTEM_UI_FLAG_IMMERSIVE_STICKY flag. Note that the "sticky" version
of the flag doesn't trigger any listeners, as system bars temporarily
shown in this mode are in a transient state.
The recommendations for using sticky/non sticky immersion:
If you're building a truly immersive app, where you expect users to
interact near the edges of the screen and you don't expect them to
need frequent access to the system UI, use the IMMERSIVE_STICKY flag
in conjunction with SYSTEM_UI_FLAG_FULLSCREEN and
SYSTEM_UI_FLAG_HIDE_NAVIGATION. For example, this approach might be
suitable for a game or a drawing app.
However, you mention users needing the keyboard, so I suggest this:
Use Non-Sticky Immersion
If you're building a book reader, news reader, or a magazine, use the
IMMERSIVE flag in conjunction with SYSTEM_UI_FLAG_FULLSCREEN and
SYSTEM_UI_FLAG_HIDE_NAVIGATION. Because users may want to access the
action bar and other UI controls somewhat frequently, but not be
bothered with any UI elements while flipping through content,
IMMERSIVE is a good option for this use case.
2. Solution
My solution is to set up your view ui in the onActivityCreated of your fragments.
My example taken from ImmersiveModeFragment.java sample.
#Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final View decorView = getActivity().getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener(
new View.OnSystemUiVisibilityChangeListener() {
#Override
public void onSystemUiVisibilityChange(int i) {
hideSystemUI();
}
});
}
Create a separate method to manage the ui that you call from your OnSystemUiVisibilityChangeListener()
Taken from here non sticky immersion
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
You can then call this method again onResume.
onResume(){
hideSystemUI();
}
3. Alternate solution.
If sticky immersion is what you really want you need to try a different approach.
For sticky immersion
#Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);}
}
I hope this solves your problems.
I know this is old but I was struggling with this for a while as I had dialogFragments and a drop down in my navigationView that kept revealing the system UI needlessly. Here are the things I did that ended up working (the first two pieces I found a lot of places):
In my AndroidManifest.xml on the application
android:theme="#style/AppTheme.NoActionBar"
In my activity
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
decorView.setSystemUiVisibility(uiOptions);
And what ended up being the key for me is in my styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
Is it possible to stop the softkeyboard for changing the UI mode?
Maybe
Is it possible to stop the showing of DialogsFraments from changing the UI mode?
Yes if only you try to understand what you are doing
If neither is possible why does the app get stuck in the wrong UI mode when there is both a shown keyboard and DialogFrament?
because of the answer on question 2
now this is your overall solution
The current/Focused View is who the os takes UI visibility settings from,when a View is obscured or is not on top in respect to the z-order then setSystemUiVisibility() is set to its default. So instead try hacking around
View decorView = getWindow().getCurrentFocus() != null ?
getWindow().getCurrentFocus() :getWindow().getDecorView();
and whenever your DialogFragment is dismissed check for the above line and re-call your accessibility ui codes; because .... guess is lucid to this point
In Dialog or BottomSheetDialogFragment you have to implement this solution which is work for me.
Step 1:
In your dialog or BottomSheetDialog, write this code in onActivityCreated method,
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
var viewParent = view
while (viewParent is View) {
viewParent.fitsSystemWindows = false
viewParent.setOnApplyWindowInsetsListener { _, insets -> insets }
viewParent = viewParent.parent as View?
}
}
Step 2: Also, override the below method :
override fun setupDialog(dialog: Dialog, style: Int) {
super.setupDialog(dialog, style)
dialog?.window?.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
}
Now see the magic :)
This fix, plus another fix related to the soft keyboard is included in the DialogFragment class from this library. Just extend this instead of the standard library:
https://github.com/marksalpeter/contract-fragment
The main purposes of the library is to add delegate functionality to Fragments and DialogFragments that leverage the parent/child fragment relationship, but you can just use the bug fix or copy/paste the file
I am trying to come up with some ways of disabling the status bar without hiding it completely. This is an introlude attempt at disabling status bars in 3rd party apps. For now, I want to disable it in my own app, and then eventually create a background service to see if I can do so in other apps. The app I am creating is an operating system for children, and I am trying to develop a closed system.
Here is what I have tried. My initial idea was to monitor when status bar was accessed and then closing it.
#Override
public void onWindowFocusChanged(boolean hasFocus) {
Log.i(TAG, "onWindowFocusChanged()");
try {
if (!hasFocus) {
Log.d(TAG, "close status bar attempt");
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class
.forName("android.app.StatusBarManager");
Method collapse = statusbarManager.getMethod("collapse");
collapse.setAccessible(true);
collapse.invoke(service);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
This is the method I used. It works for detecting when status bar is being accessed, however, it does not close the status bar once it has focus. What am I missing? Thanks in advance.
I have found answer to my question. First, I was missing the following permission
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
With that permission, the following code now works really well.
#Override
public void onWindowFocusChanged(boolean hasFocus) {
Log.i(TAG, "onWindowFocusChanged()");
try {
if (!hasFocus) {
Log.d(TAG, "close status bar attempt");
//option 1
int currentApiVersion = android.os.Build.VERSION.SDK_INT;
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class
.forName("android.app.StatusBarManager");
if (currentApiVersion <= 16) {
Method collapse = statusbarManager.getMethod("collapse");
collapse.setAccessible(true);
collapse.invoke(service);
} else {
Method collapse = statusbarManager.getMethod("collapsePanels");
collapse.setAccessible(true);
collapse.invoke(service);
}
// option 2
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mContext.sendBroadcast(it);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
If you notice, there is a second option as well that I found to be working good. You can comment out option 1 if you want to use option 2, or vise versa. Both accomplish the same thing, although I believe option 2 is better.
Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mContext.sendBroadcast(it);
The only downfall I found is that it is slow(er) when closing. However, both methods collapse quick enough to where no one can click on any notifications or options in the status bar. Hopefully this is helpful to someone else. Good luck, Cheers!
I am also working on the same thing. With Android 5.0 Lolipop they have released Screen Pinning mode (which is essentially Kiosk mode) which does a few things:
The status bar is blank, and user notifications and status information are hidden.
The Home and Recent Apps buttons are hidden.
Other apps cannot launch new activities.
The current app can start new activities, as long as doing so does not create new tasks.
When screen pinning is invoked by a device owner, the user remains locked to your app until the app calls stopLockTask().
If screen pinning is activity by another app that is not a device owner or by the user directly, the user can exit by holding both the Back and Recent buttons.
You can read about it further in the Android 5.0 Lolipop release documentation.
However, if you are looking for a more controlable solution, then you may want to create a custom ROM. Here is a great overview on making Kiosk applications (which also require disabling status bar).
Developing Kiosk Mode Applications in Android Tutorial
Here's an updated answer if anyone is still looking for a solution to something like this: https://developer.android.com/training/system-ui/immersive.html
For me, I added the following in my onResume() method:
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
This allows the status bar to stay hidden but the user can still access it by swiping the edge of the screen. Then after a few seconds of inactivity it will collapse and disappear again!
I'm attempting to remove the navigation bar programatically using the most commonly found method on the internet - however the navigation bar continues to appear.
I've debugged the method and it is not throwing an exception - so I'm really not sure why we can't seem to hide the Navigation Bar using the following code:
(any suggestions are greatly appreciated)
Source:
try
{
Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 42 s16 com.android.systemui"});
proc.waitFor();
}
catch(Exception ex)
{
//Toast.makeText(getApplicationContext
Try doing this, somewhere after you have set your content's view
To hide your navigation bar
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
To hide your keyboard
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
For more on the navigation bar, since it is what your question explicitly asks for, take a look here: Hiding the Navigation Bar
i have two questions:
one how can i run my application in full screen
how video players run videos in full screen.
i have tried alot and still struggling to achieve this but couldn't find a solution.
the list of solution i found but they are not fulfilling my requirements
this hides only the notification bar.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
also hides only the notification bar
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
it low profiles the navigation bar not hiding it.
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
no effect on my activity.
anyView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
note that:
i am not talking about rooting a device,so please provide those solutions which can work without rooting a device.
i am not talking about hiding only notification bar,but full screen by hiding both navigation bar and notification bar too.
i am talking about jelly beans api 4.1 or greater than 4.1 version of android
and please give answers with code.
after my research and your answers, i am getting this:
but my app should look like this without navigation bar:
i do not want the system navigation bar visible in my app.
I'm not sure what you're after, but the following hides the Notification bar, and the Soft Navigation keys (as seen on Google Nexus-devices), so the app essentially is "full screen".
Edit2
In Android 4.4 (API 19) Google introduced the new Immersive mode which can hide the status & navbar and allow for a truly fullscreen UI.
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
Reference:
https://developer.android.com/training/system-ui/immersive.html
Edit:
Tested on Android 4.3 (API 18) and Android 4.1 (API 16) with Soft Nav keys.
#Override
protected void onCreate(Bundle b) {
super.onCreate(b);
setContentView(R.layout.main);
int mUIFlag = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
}
For more information read up on http://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int)
-To hide Status bar:
A great solution I found for that issue, setting each Activity theme & windowSoftInputMode to the following values :
<activity android:name=".MyActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="adjustResize"> <!-- theme : to set the activity to a full screen mode without a status bar(like in some games) -->
</activity> <!-- windowSoftInputMode : to resize the activity so that it fits the condition of displaying a softkeyboard -->
for more info refer here.
-To hide Notification bar:
There are Two ways :
1- root your device, then open the device in adb window command, and then run the following:
adb shell >
su >
pm disable com.android.systemui >
and to get it back just do the same but change disable to enable.
2- add the following line to the end of your device's build.prop file :
qemu.hw.mainkeys = 1
then to get it back just remove it.
and if you don't know how to edit build.prop file:
download EsExplorer on your device and search for build.prop then change it's permissions to read and write, finally add the line.
download a specialized build.prop editor app like build.propEditor.
or refer to that link.
On the new android 4.4 you should add this line:
View.SYSTEM_UI_FLAG_IMMERSIVE;
So the new working solution atleast on nexus4 4.4.2 is
final int mUIFlag =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE;
Immersive alone won't work though it works when combined with other flags. see documentation for more details.
Then you add in the activity the activating of this setup as shown here before (I am just adding for consistency)
getWindow().getDecorView().setSystemUiVisibility(mUIFlag);
I made 2 layouts one for regular size and one for full screen and inside full scrreen I get the devices size and and assign it to video player
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getRealSize(size);
int w=size.x;
int h=size.y;
videoPlayer.setFixedSize(w, h);
I think you cant hide the system bar in android 4.0 > (only in tablets, in phones you should be able to)
What you can do is to hide the icons and to disable some buttons(everyone except home)
You can try this:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
}
Also for disabling the buttons:
This is for back button:
public boolean onKeyDown(int keyCode, KeyEvent event) {
return false;
}
This for the menu:
#Override
public void onWindowFocusChanged(boolean hasFocus) {
try
{
if(!hasFocus)
{
Object service = getSystemService("statusbar");
Class<?> statusbarManager = Class.forName("android.app.StatusBarManager");
Method collapse = statusbarManager.getMethod("collapse");
collapse .setAccessible(true);
collapse .invoke(service);
}
}
catch(Exception ex)
{
}
}
Video Players run in full screen by setting the
myView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
setFlags() before setContentView(View)
This will show the system bar on any user interaction, just like video players do.
The closest you can get to running your app full screen is by setting in Lights Out mode, the system buttons will appear as dots.
To use the lights out mode just use any view in your activity and call
anyView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
For Hiding the navigation bar use this in your onStart() so that every time you get to that activity it will be in full screen mode.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
I hope this helps !
Android Version: 4.2.2 - Device: Vega Tablet
Android App to Hide Status and System Bar and displaying complete screen I followed these steps.
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name">
<activity
android:name=".MainActivity"
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>
MainActivity.java
super.onCreate(savedInstanceState);
getWindow().getDecorView().setSystemUiVisibility(0x10);
setContentView(R.layout.activity_main);
Above code perfectly worked for my app.
go to your manifest and add this to your activity
<activity
android:name="yourPackage.yourActivity"
android:theme="#android:style/Theme.Black.NoTitleBar">
i create a lockscreen application.. this application is triggered by SMS.. when a SMS containing command was received, it will display a lock screen activity.
my lockscreen activity is using TYPE_KEYGUARD for disabling a home screen button. When device screen turn off and then i turn it on again, my problem is status bar / notification bar still appear on my screen. this is a problem because the user still can access some program through status bar / notification bar even the device is being locked. so i want to dissapear this status bar / notification bar so that the user (theft) can't access that device anymore..
Please help me to solve this..
I think what you're trying to do is programmatically set an activity as fullscreen. If so, consider the following:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Source: http://www.androidsnippets.com/how-to-make-an-activity-fullscreen
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
only disables the activity's title bar, not the notification bar at the top.
Use this theme in android manifest for your activity :
"Theme.NoTitleBar.Fullscreen"
did work for me.
It hides the notification bar.
On Android 4.0 and lower
Option 1:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
Option 2:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the Android version is lower than Jellybean, use this call to hide
// the status bar.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.activity_main);
}
...
}
on Android 4.1 and Higher
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
And for Android 4.6(Api 19) and higher use the Immersive Full-Screen
Mode
Reference from Google