Bluetooth setPin Android 9 Pie больше не работает - PullRequest
0 голосов
/ 04 апреля 2019

Я недавно получил Android 9.0 на моем устройстве Huawei Mate 9. До этого у меня был Android 8, и BluetoothDevice.setPin до этого работал нормально. Любые подсказки, почему это больше не работает?

public class BlututReceiver extends BroadcastReceiver {
        private final static byte[] PIN = "0000".getBytes();

        public void onReceive(android.content.Context r7, android.content.Intent intent) {
            BluetoothDevice bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            String action = intent.getAction();
            if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action)) {
                sendPin(bluetoothDevice);
            }
        }

        private void sendPin(BluetoothDevice bluetoothDevice) {
            try {
                Thread.sleep(100);
                bluetoothDevice.setPin(PIN);
                bluetoothDevice.createBond();
                //bluetoothDevice.setPairingConfirmation(true);
                //bluetoothDevice.getClass().getMethod("setPairingConfirmation", new Class[]{Boolean.TYPE}).invoke(bluetoothDevice, new Object[]{Boolean.valueOf(true)});
            } catch (Exception e) {
                Log.e("BLUETOOTHSETPINERR",e.getMessage());
            }
        }
    }




<receiver android:name=".Utile.BlututReceiver">
            <intent-filter android:priority="1000">
                <action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
            </intent-filter>
        </receiver>

1 Ответ

0 голосов
/ 24 июля 2019

Отлично работает в Xiaomi Mi 9 с Android Pie. Кажется, проблема Huawei. Я пытался с HUAWEI P10 и HUAWEI PSMART (оба с Android Pie), и он не работает.

...