4

I'm making Cosu application and it's running on locktask mode. I have found guides to make NavigationBar and ActionBar fully transparent and hidden but if user swipes from bottom or top of the screen it will show back button on bottom NavigationBar.

I have added code snippet that hides it again quickly.

/* Hides Navigation bar again if user swipes it visible */
@Override
protected void onResume() {
        getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(
                new View.OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                    getWindow().getDecorView().setSystemUiVisibility(flags);
                    }
                });
    super.onResume();
}

Is there any way to actually change that back button icon or it's color to transparent using styles or something?? I have tried to find out information on this but what i have found is using extra applications to modify back button image.

I can disable back button event by using following code but doesn't hide it's visibility

@Override
public void onBackPressed() {
     // nothing to do here
}
Juge
  • 536
  • 8
  • 21
  • Add some code to your query – Sadiq Md Asif Jan 11 '17 at 09:50
  • You can check this article for system customization with disabling navigation bar: https://www.androidexplained.com/how-to-disable-navigation-bar/ – Nick Titov Jan 16 '17 at 13:59
  • Thanks @NickTitov for the help but i don't want to disable whole bar. Only get rid of back button showing when in task lock mode. Still good to know that method also. – Juge Jan 17 '17 at 11:09

2 Answers2

2

You can add this dependency to you build.gradle(app):

https://github.com/topjohnwu/libsu

android {
    compileOptions {
        // This library uses Java 8 features, this is required
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    ...
    implementation "com.github.topjohnwu.libsu:core:3.1.1"
    ...
}

After that, add this line to your build.gradle(project):

repositories {
    maven { url 'https://jitpack.io' }
}

Then, you can use this function for hide all buttons on nav bar:

private fun disable backButtonOnLockTaskMode(){
    Shell.enableVerboseLogging = BuildConfig.DEBUG
    Shell.setDefaultBuilder(
        Shell.Builder.create()
            .setFlags(Shell.FLAG_REDIRECT_STDERR)
            .setTimeout(10)
        ) 
    Shell.su("settings put secure sysui_nav_bar \"space;space;space\"").exec()             
}

In other hand, you can change the string in command, but the success in that command it depends on your lock task mode implementation:

  • "space;space;space": No icons.
  • "space;back;space": Only back icon.
  • "space;volume_sub,back,volume_add;space": With volume buttons.

I hope it's help you!

Greetings!

-4

No, it is impossible, because everybody will be able to make screen lockers and viruses. You will be able to do it with your own Android OS build only.

Nick Titov
  • 588
  • 5
  • 19
  • 7
    This question is specifically related to COSU (corporate-owned, single-use) devices, like kiosks. A 'screen-locker' is exactly the sort of thing you want on a kiosk - you won't be downloading these apps in the Play store. – Tim Krins Jan 16 '17 at 12:47