I need to check if a certain android device has a hardware button in code. For example only some phones have the search button.
So how do I check if a device has a hardware button(Search, camera, d-pad, etc) or not?
I need to check if a certain android device has a hardware button in
Share
You can use
PackageManager.hasSystemFeature().Example:
You can also get some of the features which are not testable by the
PackageManagervia theConfiguration, e.g. the DPAD.The only exception is the search button. There was a question here a few days ago, asking basically the same. I don’t remember any answer and I don’t know a way to detect the search button, since it’s not in the list of features. (Edit: There you go, possible duplicate thread is the one i mentioned here)