Is it possible to detect if a hardware keyboard exists on a device?

TomA

Active Member
Licensed User
Longtime User
I wondered if it is possible within B4A to detect whether or not a device has a hardware keyboard? As a more general question, is it possible to detect what features a device actually has in it?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this method (requires Refection library):
B4X:
Sub HardwareKeyboardPresent As Boolean
   Dim r As Reflector
   r.Target = r.GetContext
   r.Target = r.RunMethod("getResources")
   r.Target = r.RunMethod("getConfiguration")
   Dim keyboard As Int = r.GetField("keyboard")
   Return keyboard <> 1 'KEYBOARD_NOKEYS 
End Sub
See this page for other features: Configuration | Android Developers
 
Upvote 0
Top