Android Question On no title app, how to detect no menu button

BumForALiving

Member
Licensed User
Longtime User
I turn off the title in my app for more screen real estate which means on newer versions the overflow button does not appear. On my phone (Droid 4) I have a physical Menu button. I know I can remove android:targetSdkVersion="14" from the manifest and have the overflow button appear on the lower soft button menu but I like the appearance of the higher SDK.

Is there a way to detect if a physical menu button (or software on some versions? Not sure, new to android programming) is available? My thought is to only put a settings button or action bar only if needed.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code:
B4X:
Sub HasPermanentMenuKey As Boolean
   Dim r As Reflector
   If r.GetStaticField("android.os.Build$VERSION", "SDK_INT") >= 14 Then
     r.Target = r.RunStaticMethod("android.view.ViewConfiguration", "get", _
       Array As Object(r.GetContext), Array As String("android.content.Context"))
     Return r.RunMethod("hasPermanentMenuKey")
   End If
   Return True
End Sub
 
Upvote 0
Top