The ADB command you provided enables the gesture navigation overlay in Android's System UI, specifically for gesture-based navigation (as opposed to the traditional 3-button navigation bar).
In Java (or Kotlin) for Android, there is no direct public API to enable or disable navigation overlays like this programmatically. The overlay system is managed by the Android system and is typically controlled via ADB or system settings.
However, if you want to check or change the navigation mode (gesture vs. 3-button) programmatically, you can use the Settings.Secure API to interact with the relevant system settings.
You can check the current navigation mode using the following code:
javaimport android.provider.Settings; public boolean isGestureNavigationEnabled(Context context) { return Settings.Secure.getInt( context.getContentResolver(), "system_navigation_keys_enabled", 1 // Default is 1 (3-button navigation) ) == 0; // 0 means gesture navigation is enabled }
To change the navigation mode, you would need root access or to be a system/privileged app, as this is a secure setting. Here’s how you might attempt it:
javaimport android.provider.Settings; public void setGestureNavigationEnabled(Context context, boolean enable) { Settings.Secure.putInt( context.getContentResolver(), "system_navigation_keys_enabled", enable ? 0 : 1 // 0 for gesture, 1 for 3-button ); }
Note:
adb shell cmd overlay enable ...) is a system-level command and cannot be directly replicated in a standard Android app.If you want to guide users to enable gesture navigation, you can direct them to the Settings app:
javaIntent intent = new Intent(Settings.ACTION_DISPLAY_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);
Or, for newer Android versions, you can use:
javaIntent intent = new Intent(Settings.ACTION_GESTURE_NAVIGATION_SETTINGS); context.startActivity(intent);
Summary:
There is no direct Java API equivalent for the ADB overlay command, but you can interact with the navigation mode via Settings.Secure (with limitations) or guide users to the settings page.