Android - Removing home and navigation button
Asked Answered
M

6

9

I'm trying to remove the Home button and the Multithread button. The idea is to remove it completely from the running application, better if we can remove it completely from every application on the tablet we are working with. Using full-screen is not something that we want, since the user shouldn't be able to exit the full screen mode, even if he wants it (it's a custom commercial app, it's the desired behaviour for multiple reasons).

Nexus 10 without the home and navigation buttons

This is the result on a Nexus 10. We accomplished that by taking the SystemUI sources and changing them before compiling the CyanogenMod.

Unfortunately we have to replicate that in an Asus ZenPad 10, that has no CyanogenMod available. We have a version that allows us to create system applications, but change every application into a system application is not something that we want.

We have found in this link: http://developer.oesf.biz/em/developer/reference/eggplant/constant-values.html#android.view.View.STATUS_BAR_DISABLE_HOME

That there are flags for disabling the home button and the navigation button, but they are usable only with system applications.

We have tried to get the SystemUI.apk already compiled in the tablet, decompile it and change it. The problem is that or we have useless smali files or with have only res/ and AndroidManifest.xml files (Asus changed the SystemUI.apk into two apks of it own).

So... we are a little desperate here ahah. Looking for hints / ideas to try to remove that buttons. Better without recompiling or doing some strange thing.

Michaelmas answered 3/12, 2015 at 11:22 Comment(1)
You can try another hack, if you just need one app running fulscreen. You can run service in background, which will periodically check if your fullscreen application is active, and when user try to leave your app, then service immediately starts your app again. It is not exactly what you want, but maybe it can helpTwig
B
3

This is possible using a combination of permissions like Immersive Full-Screen Mode combined with the SYSTEM_UI_FLAG_HIDE_NAVIGATION and SYSTEM_UI_FLAG_FULLSCREEN flags. These flags hide the navigation and status bar, now that you have a blank screen put a linear laoyout at the bottom of the screen with only the back icon visible, just to create the effect of what you want. ALSO note that it is important to understand that once the user swipes upwards the normal navigation bar will be visible(not sure if it can be handeled through intercept touch event).

Alternatively you can try out this solution mentioned here also How to disable Home and other system buttons in Android?

also refer this github project(works if there is only a hardware navigation buttons) https://github.com/shaobin0604/Android-HomeKey-Locker

Last But not the least There is an answer by commsware that throws more light on this subject might come in handy. Not able disable Home button on specific android devices

Barela answered 7/12, 2015 at 12:21 Comment(7)
thank you, but I've tried every solution you proposed but nothing suits the case. The first one is ok, but we need a permanent solution, not something that the user can avoid. Actually, the launcher already deleted the buttons, but the activity of our app puts them back again.. maybe we can try to avoid that the activity resets the buttons (no idea how to do it though)Michaelmas
Including immersion mode check this out. developer.android.com/training/system-ui/immersive.htmlBarela
yeah, the use can escape from thatMichaelmas
Did android device owner setting fail alsoBarela
I haven't understood... :(Michaelmas
Check this out github.com/googlesamples/android-DeviceOwner I think this should be a starting pointBarela
seems like it doesn't fit for my problemMichaelmas
S
1

Try Android for work APIs and refer here.Using this apis you can get full control of the device and disable whatever you want.The device can be used only for single app.

Corporate-owned, single-use (COSU) is a subset of the corp-liable scenario for shared or special-use devices. Unlike corp-liable devices that are associated with individual employees, COSU devices are associated with particular business functions. For example, a COSU device might be used as a kiosk.

You can also try to integrate custom MDM(Mobile device management) solution provided by OEMS/MDM vendors/MDM partners like Samsung, HTC, Airwatch etc. This work on devices prior to lollipop too and provide more APIs to control the device than provided by default android solution.

I know Samsung MDM/Knox solution is good and it has APIs to control each and every part of the device.Refer- http://www.samsung.com/levant/business/solutions-services/mobile-solutions/security/mobile-device-management.They have Kiosk mode which is similar to COSU.

Schnapp answered 13/12, 2015 at 18:58 Comment(4)
thanks for the tip. It looks like it's the best answer but I have to check if it really works on lollipop. Working on it :)Michaelmas
I have to wait for an answer by google :( we'll see if they will answer in timeMichaelmas
@Michaelmas I guess it works on lollipop too. Otherwise you can try solutions provided by OEMS/other vendors if its feasible. Updated the answer too.Schnapp
not sure whether this works or not. I've asked to get the access to Android Work.. still nothing. Thanks for the answer thoughMichaelmas
N
0

You will ask permission to the user. In this car this is yourself. Be careful since you will have to implement a way back out of the application.

Reference: disable home

Or you just could buy a case to stick it around, so the buttons won't be visible...

Nawab answered 3/12, 2015 at 11:57 Comment(7)
unfortunately that solution isn't permanent.. is it? We should avoid the user to enable the navigation bar back againMichaelmas
How are you going to enable it back again, if it is permanent?Nawab
Something like that: play.google.com/store/apps/… ?Nawab
you won't. The idea is to sell the tablet to the client without the home and navigation buttons, to prevent him to exit from the only application on it. We have tried to put the "button removal" in the launcher. Actually it worked in the home screen, but when we start the application, the button appears back again. wtf? ahah :) thanks for help though!Michaelmas
You should find a seller of devices and ask for this. You shouldn't buy tablets and sell them tweaked. And why would you do this ?Nawab
Already done, we are currently asking to have a custom version without the navigation bar and the home button, but still if we find an easier solution, we will use itMichaelmas
Let us continue this discussion in chat.Nawab
H
0

use immerse mode, use this code in onResume() so that everytime you get back to your activity its ran and they are hid

View decorView = getWindow().getDecorView();
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);
Helvetian answered 8/12, 2015 at 2:18 Comment(1)
yeah, but it's not fixed. The user can escape from thatMichaelmas
M
0

Of course, you can't REMOVE any System Buttons like Power, Volume +/-, Home, Back or Menu. You can only hide or show Home, Back or Menu only when they are virtual(opposite to Solid Buttons).

Meanwhile, hiding the navigation bar is limited. It only can be completed on Android 4.0 and higher. So, if you want to do this, you need to use 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);

And, if you want to set your application's content to appear behind the navigation bar, you need the SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION flag. You may also need to use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain a stable layout.

Malaco answered 14/12, 2015 at 9:30 Comment(0)
L
0

i have tried the same for a long period of time and searched a lot but as you know the HOME button is the only way for user to get out from any app in any situation. its very risky to block that and google will not allow it.

One thing you can do is set your application as a launcher application then u can receive keyevent Home

Licit answered 14/12, 2015 at 10:20 Comment(1)
Link-only answers are highly discouraged here because the links may become dead in the future. I suggest you edit your answer with quotes from the sources you cite.Amphithecium

© 2022 - 2024 — McMap. All rights reserved.