In InAppBrowser.java, I use
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
dialog.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
to have the browser full screen and hidden virtual navigation. It works perfectly. Problem is when I press the home button and then load the application back. At this point, I have displayed the virtual navigation. How can I achieve that the navigation is hidden again?
Add
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
dialog.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
in onResume()
Related
Don't close this question since this is very old but i cant find the solution.
I'm new to android. I want to disable the soft keys at the bottom and the status permanently once the user opens my app.
It should not appear even on user interaction.
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus){
getWindow().getDecorView().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);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}
This code just hides the navigation bar. But when i swipe from the bottom it appears. This should not happen. Please help.
To come out of my app i will provide a way.
Thanks
Don't close this question since this is very old but i cant find the solution. I'm new to android. I want to disable the soft keys at the bottom and the status permanently once the user opens my app.
It should not appear even on user interaction.
I am pretty sure you cannot disable the navigation bar permanently. Otherwise the user will be stuck with your app forever with no way of getting out of it.
I am creating a lock screen application right now. I have been searching and trying some tricks to do it but still can't find the best approach. My previous approach that I used is to use TYPE_SYSTEM_ERROR. it worked well. it prevents navigation and status bar to get any touches. it also run any other app behind my app, including the power off options dialog.
unfortunately I think this is bad because when the app got freeze or not responding, user can't do anything but force restart his/her phone.
I have been looking and analyze some existing lock screen apps in play store. They use different ways to lock the phone but I found one app that I think I can follow. It makes the nav and status bar overlay the app. nav and status bar still can be clicked but it's all opened behind the lock screen. and when I tried to open the power off dialogs, the NavigationBar still overlay the lock screen.
I changed my app to follow that approach. I am able to make the bars overlay my lock screen but I am still not able to:
1. make other app run behind my lock screen (lock screen always on top)
2. the NavigationBar stays overlay when power off dialog appear and when user move to home as well. in my case, the NavigationBar pushed up the screen and my screen looks ugly (some components move to wrong place) and after the Dialog dismissed, it doesn't move back to original position. it's fixed but I noticed a similar problem when I touch the home button and still searching to fix this.
Here's a snippet of my codes (updated):
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
mOverlay = (RelativeLayout) inflater
.inflate(R.layout.main, (ViewGroup) null);
mOverlay.setFitsSystemWindows(false);
getWindow().getDecorView().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);
mWindowManager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
mWindowManager.addView(mOverlay, params);
And here a screenshot of app in PlayStore that I want to follow:
In my app I want to remove completly the softkeys (back, home, etc).
I've managed to do that with:
getWindow ( ).getDecorView ( ).setSystemUiVisibility ( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
But when I touch the screen it comes back, and does not go away...
I also have "android:theme="#android:style/Theme.NoTitleBar.Fullscreen" on manifest and
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Does not help...
Anyone knows how to get over this?
Thanks.
I need to run VideoView in splash kiosk mode.
So I set it to fullscreen (all UI hidden, LOW_PROFILE etc). Mediacontroller not set and not exists. videoview set to not clickable in xml. VideoView OnTouch method overrided. Zorder set to -1. I tried all methods...
but!
Any touch of running VideoView shows me bottom navigation bar (back, home etc) on tablet.
System hides it automatically at 3 seconds. I can not override it :(
How to make VideoView in fullscreen - fully untouchable?
I found a solution, never seen it here.
this totally disables bottom UI on tablet (but leave upper bar on phone)
videoView.setSystemUiVisibility(View.GONE);
to hide status on phone just set in activity onCreate as usual:
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_fullscreen);
Have been fighting with this for a while, and it turns out nothing happens if you set the flags on the VideoView, but works when you do it on the mediaController:
mediaController.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
A remaining problem is that the video now doesn't seem to respond to touch at all, so the media controls are also gone.
I'm trying to replace the stock lock screen with my own app.
In my code, i want to disable the Home button.
I know how to do this in Android 2.3 and below,
but the same code doesn't work with Android 4.0+ (return to desktop when Home button pressed)
Recently I found out an app called MiHome which has its own lock screen and is able to disable the Home button.
Does anyone know how it achieves this???
There is no way to intercept the home button on Android, unless you make your app the home screen. This is for security reasons, so that malicious apps cannot take over your device by overriding all the buttons that can exit. The home button is the one sure shot way to be able to leave any app.
If you want to handle the HOME button, implement a home screen.
Mucking with the home button is disabled for security/reliability reasons in ICS. (Most apps use it for evil than good)
Please refer to the following questions for workarounds.
how can I disable android 4.0 home button
override Home key in android ICS
Disable Home Button in Android ICS (4.0)
Seems like the only way is to implement a home screen
Try this
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.TOP;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
mOverlay = (RelativeLayout) inflater
.inflate(R.layout.main, (ViewGroup) null);
mOverlay.setFitsSystemWindows(false);
getWindow().getDecorView().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);
mWindowManager = (WindowManager) context
.getSystemService(Context.WINDOW_SERVICE);
mWindowManager.addView(mOverlay, params);