Android Question detect hardware button exists or not

Erel

Administrator
Staff member
Licensed User
You can use this code to check for the menu button:
B4X:
Sub HasPermanentMenuKey As Boolean
   Dim vc As JavaObject
   vc = vc.InitializeStatic("android.view.ViewConfiguration").RunMethod("get", Array(GetContext))
   Return vc.RunMethod("hasPermanentMenuKey", Null)
End Sub

Sub GetContext As JavaObject
  Return GetBA.GetField("context")
End Sub

Sub GetBA As JavaObject
  Dim jo As JavaObject
  Dim cls As String = Me
  cls = cls.SubString("class ".Length)
  jo.InitializeStatic(cls)
  Return jo.GetFieldJO("processBA")
End Sub
 
Upvote 0

palmzac

Active Member
Licensed User
Thanks Erel :)

You can use this code to check for the menu button:
B4X:
Sub HasPermanentMenuKey As Boolean
   Dim vc As JavaObject
   vc = vc.InitializeStatic("android.view.ViewConfiguration").RunMethod("get", Array(GetContext))
   Return vc.RunMethod("hasPermanentMenuKey", Null)
End Sub

Sub GetContext As JavaObject
  Return GetBA.GetField("context")
End Sub

Sub GetBA As JavaObject
  Dim jo As JavaObject
  Dim cls As String = Me
  cls = cls.SubString("class ".Length)
  jo.InitializeStatic(cls)
  Return jo.GetFieldJO("processBA")
End Sub
 
Upvote 0
Top