How can I find hardware properties at runtime? I want to be able to know if the device has a physical keyboard, d-pad, trackball, etc.
The preferred way of handling different hardware configurations seems to be to define different Resources and let Android pick the relevant one for the hardware. The documentation says:
You can supply different resources for your application to use depending on the UI language or hardware configuration on the device. Note that although you can include different string, layout, and other resources, the SDK does not expose methods to let you specify which alternate resource set to load. Android detects the proper set for the hardware and location, and loads them as appropriate.
However, there is nothing stopping you having a number of versions of a properties files in your application and using these to determine the hardward configuration. For example, one version of the file would contain dpad = true
and another would have dpad = false
and Android would pick the version of the file that matched the hardware and then you can read the dpad
property. Admittedly, this would be rather tedious but I can't find easier way in the API to do this.