Android examples for Bluetooth:Bluetooth Bond
set Pin for bluetooth via reflection
//package com.java2s; import java.lang.reflect.Method; import android.bluetooth.BluetoothDevice; import android.util.Log; public class Main { static public boolean setPin(Class btClass, BluetoothDevice btDevice, String str) throws Exception { Boolean returnValue = false; try {/*from w ww.j a v a 2 s .c o m*/ Method removeBondMethod = btClass.getDeclaredMethod("setPin", new Class[] { byte[].class }); returnValue = (Boolean) removeBondMethod.invoke(btDevice, new Object[] { str.getBytes() }); Log.e("returnValue", "" + returnValue); } catch (SecurityException e) { // throw new RuntimeException(e.getMessage()); e.printStackTrace(); } catch (IllegalArgumentException e) { // throw new RuntimeException(e.getMessage()); e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return returnValue; } }