5

My application requires users to hold down the trackball in order to access an advanced menu. Not all phones have a trackball, however, so I need to remove this requirement for such phones. Is there a way to detect if the phone has a trackball?

Aaron C
  • 3,328
  • 1
  • 24
  • 22

1 Answers1

5

Use the Configuration object, specifically the navigation and navigationHidden fields. You can get a Configuration object via getResources().getConfiguration().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • This isn't really an answer... HOW do the navigation and navigationHidden fields help?? – Rich Jun 22 '11 at 18:53
  • @Rich Presumably check if navigation is NAVIGATION_TRACKBALL (possibly allow NAVIGATION_DPAD too), indicating that a trackball (or D-pad) exists, and navigationHidden is not NAVIGATIONHIDDEN_YES, indicating that the trackball is not currently covered up by a folding/sliding mechanism. – Chris Boyle Oct 08 '11 at 23:16