问题描述
我正在开发一个应用程序,我想在其中连接蓝牙设备的主要问题是我不希望用户输入所需的 pin 而应用程序应该自己完成...我没有任何与连接相关的问题...只想自己插入并完成pin认证过程.
I am developing an application where I want to connect a Bluetooth device main issue is I don't want user to enter required pin instead application should do that by himself...I don't have any connection related issue...Only want to insert and complete pin authentication process by application itself.
我发现以下代码我确定它可以工作但不确定如何在此代码中添加 pin??
I found following code I am sure it is working but not sure on how to add pin in this code??
private void pairDevice(BluetoothDevice device) {
try {
Log.d("pairDevice()", "Start Pairing...");
Method m = device.getClass().getMethod("createBond", (Class[]) null);
m.invoke(device, (Object[]) null);
Log.d("pairDevice()", "Pairing finished.");
} catch (Exception e) {
Log.e("pairDevice()", e.getMessage());
}
}
有谁知道如何在上面的代码或任何类似的代码中输入 pin 来解决问题..谢谢
Does anyone know how to enter pin in above code or any similar code to solve problem..Thank You
推荐答案
我在进行程序化配对时如何避免或关闭 Android 的蓝牙配对通知?
这似乎给了你答案,输入和所有.它涉及在您收到消息时发送 .setPin().
This seems to give you the answer, with the pin entering and all. It involves sending .setPin() whenever you get the message.
这篇关于如何以编程方式配对蓝牙设备 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!