title: Android.bluetooth.IBluetooth.createBond() not found in 4.2.1 but works in earlier OS versions
body: <p>I have some code to automatically pair with a bluetooth device by calling createBond(), registering a broadcast receiver for android.bluetooth.device.action.PAIRING_REQUEST and then manually entering the PIN code to pair.</p>
  
  <p>This has worked great with all devices tested so far up to Andoid 4.0 but today I tried this on my Nexus 7 with Android 4.2.1 and got the following error:</p>
  
  <p>java.lang.noSuchMethodException: android.bluetooth.IBluetooth.createBond</p>
  
  <p>Did they actually remove this function from the library?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>What's actually happening is the IBluetooth interface object that I am using to call createBond is not being initialized. In the following code the line that tries to get the IBinder named BTBinder returns null when this process fails causing BTInterface to be set to null at the end. So, my question now is why on my Nexus 7 with Android 4.2.1 does the call to get the binder return null but works correctly on 5 other devices I've tested?</p>
  
  <pre><code>public static IBluetooth getBluetoothInterface()
  {
      //Gets a bluetooth interface from private Android system API
      IBluetooth BTInterface = null;
  
      try
      {
          Class&lt;?&gt; ServiceManager = Class.forName("android.os.ServiceManager");
          Method getService = ServiceManager.getDeclaredMethod("getService", String.class);
          IBinder BTBinder = (IBinder) getService.invoke(null, "bluetooth");
          Class&lt;?&gt; IBluetooth = Class.forName("android.bluetooth.IBluetooth");
          Class&lt;?&gt;[] IBluetoothClasses = IBluetooth.getDeclaredClasses();
          Class&lt;?&gt; IBluetoothClass0 = IBluetoothClasses[0];
          Method asInterface = IBluetoothClass0.getDeclaredMethod("asInterface",IBinder.class);
          asInterface.setAccessible(true);
          BTInterface = (IBluetooth) asInterface.invoke(null, BTBinder);
      }
      catch (Exception e)
      {
          return null;
      }
  
      return BTInterface;
  }
  </code></pre>