Android Question [SOLVED] How to determine user's system navigation mode (BACK button or side swipe)

JackKirk

Well-Known Member
Licensed User
Longtime User
I would like to improve my apps interaction with users.

Specifically in the area of "the BACK button".

At the moment, when necessary, I just prompt the user "Please tap BACK button" or similar.

And my assumption is they will be using either 2 or 3 button navigation and therefore will have a BACK button to tap.

But if they are using gesture navigation (on my Pixel3 [Settings] > [Accessibility] > [System controls] > [System navigation] > [Gesture navigation]) then this assumption is wrong and I should adjust my prompt to something like "Please swipe left or right from edge of screen to go back" or similar.

So I want to be able to establish what mode of system navigation is in use.

I have had no luck searching the forums and googling gave me:

https://stackoverflow.com/questions/74091225/get-status-of-system-navigation-bar-in-android

the last answer is:


which looks promising but googling "isGestureNavigationMode" gives nothing of value.

I am rapidly getting out of my pay grade, any help appreciated...
 

Spavlyuk

Active Member
Licensed User
isGestureNavigationMode is the name given by the author of the answer so it's unlikely google will give you good results. Try the following.

B4X:
Dim ContentResolver As Object = Null.As(JavaObject).InitializeContext.RunMethod("getContentResolver", Array())
Dim NavigationMode As Int = Null.As(JavaObject).InitializeStatic("android.provider.Settings.Secure").RunMethod("getInt", Array(ContentResolver, "navigation_mode"))
Log(NavigationMode)
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
and from google settings source (for above):
* Navigation bar mode.
* 0 = 3 button
* 1 = 2 button
* 2 = fully gestural
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Thanks Spavlyuk and drgottjr - tried your suggestions out and they work as advertised.

2 spot on answers inside 12 hours - the B4X forums are brilliant!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…