title: Check if Android device has software or hardware navigation buttons
body: <p>I'm writing an Android app with a transparent navigation bar. To adjust the layout accordingly, I need to know whether the device has software or hardware buttons.</p>
  
  <p>During my research I came across the following solutions:</p>
  
  <pre><code>boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
  </code></pre>
  
  <p>This approach does not work on some new devices like the Samsung Note 4 or the HTC One which do not have a menu key, but still have hardware buttons.</p>
  
  <pre><code>boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
  boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
  boolean hasHardwareButtons = hasBackKey &amp;&amp; hasHomeKey;
  </code></pre>
  
  <p>This does not work as well, because some devices like the Sony Xperia Z3 Compact return true although it has a software navigation bar.</p>
  
  <p>Is there any reliable way to find out whether there are physical buttons or a software navigation bar?</p>