Android examples for android.bluetooth:Bluetooth
set Pin for blue tooth device
import java.lang.reflect.Method; import android.bluetooth.BluetoothDevice; public class Main { static public boolean setPin(Class<?> btClass, BluetoothDevice btDevice, String str) throws Exception { try {//from w w w . j ava 2s . com boolean result = false; int count = 0; Method removeBondMethod = btClass.getDeclaredMethod("setPin", new Class[] { byte[].class }); while (!result && count < 3) { result = (Boolean) removeBondMethod.invoke(btDevice, str.getBytes()); count++; } } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return true; } }