Android Bluetooth设备的SetPin方法始终返回false

Android Bluetooth设备的SetPin方法始终返回false,android,bluetooth,Android,Bluetooth,我想以编程方式配对Bluetooth设备,而无需用户交互。因此,我尝试了setPin()和setPasskey()方法,但这两种方法总是返回false。对于这个问题,我得到了他的帮助 我使用的代码是: private void PairDevice(BluetoothDevice pDevice, String pin) { try { Log.d("pairDevice()", "Start Pairing..."); Method pa

我想以编程方式配对Bluetooth设备,而无需用户交互。因此,我尝试了setPin()setPasskey()方法,但这两种方法总是返回false。对于这个问题,我得到了他的帮助

我使用的代码是:

private void PairDevice(BluetoothDevice pDevice, String pin)
{
    try
    {   
        Log.d("pairDevice()", "Start Pairing...");

        Method pairMethod = pDevice.getClass().getMethod("setPin", new Class[] {byte[].class});
        Boolean lReturn = (Boolean) pairMethod.invoke(pDevice, pin.getBytes("UTF8"));
        Log.e("pairDevice",""+lReturn);

        if(lReturn.booleanValue())
        {
            Log.d("pairDevice()", "Pairing Finished...");

            Method bondMethod = pDevice.getClass().getMethod("createBond");
            bondMethod.invoke(pDevice);
            Log.d("pairDevice()", "createBond Finished...");
        }           
    }
    catch(Exception ex)
    {
        Log.e("pairDevice()", ex.getMessage());
    }
} 
我做错了什么?有没有其他方法可以与蓝牙设备配对而不需要用户交互