我如何在共进晚餐的Android preSS蓝牙配对请求对话框(API 19)? [英] How do I suppress the bluetooth pairing request dialog in Android(api 19)?
问题描述
我使用的是从API 19 setPin()与蓝牙设备配对自动。我通过广播接收机做到这一点...检查配对请求,然后自动配对。这样做的原因是为了保持用户不必重新输入PIN码后,他们已经在我的应用程序改变了它。
有没有办法用晚餐preSS蓝牙配对请求的通知/对话框?我的code正确地改变了手机上的PIN码,并连接到设备,从而使部分是没有问题的。我只是想摆脱对话框/弹出窗口,使用户不会混淆。如果弹出了一秒钟,只要它会自动随之关闭,我不介意。
私人最终的BroadcastReceiver mReceiver =新的广播接收器(){
@覆盖
公共无效的onReceive(上下文的背景下,意图意图){
字符串行动= intent.getAction(); //从意向获取BluetoothDevice类对象
如果(btDevice.ACTION_PAIRING_REQUEST.equals(动作)){
Log.i(TAGXXXXXXXXXXXXXX配对请求收到XXXXXXXXXXXXXXXX); INT bondState = btDevice.getBondState(); 如果(bondState == || BluetoothDevice.BOND_NONE == bondState BluetoothDevice.BOND_BONDING){
字符串pinString = settings.getString(com.hiqautomation.iopener.pin,NULL); 字节[] = pinBytes pinString.getBytes();
btDevice.setPin(pinBytes);
}
}
}
};
你有任何与此运气?
我也做了同样的事情......下面应该帮助....
方法M = bt_device.getClass()实现getMethod(cancelBondProcess(类[])为空)。
m.invoke(bt_device,(对象[])NULL);
出于兴趣,如何输入PIN你什么时候隐藏软键盘。这是问题的即时通讯目前正与在玩<一个href=\"http://stackoverflow.com/questions/25290319/android-how-to-disable-soft-keyboard-during-bluetooth-pairing\">Android - 蓝牙配对过程中如何禁用软键盘
垫
I'm using setPin() from api 19 to automatically pair with a bluetooth device. I do this via broadcast receiver...checking for pairing requests, then automatically pairing. The reason for this is to keep the user from having to re-enter a pin once they've changed it in my app.
Is there a way to suppress the notification/dialog of the bluetooth pairing request? My code changes the PIN on the phone correctly and connects to the device, so that part is not a problem. I just want to get rid of the dialog/popup so users aren't confused. I don't mind if it pops up for a second, as long as it automatically gets closed.
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// Get the BluetoothDevice object from the Intent
if (btDevice.ACTION_PAIRING_REQUEST.equals(action)) {
Log.i(TAG, "XXXXXXXXXXXXXX PAIRING REQUEST RECEIVED XXXXXXXXXXXXXXXX");
int bondState = btDevice.getBondState();
if (bondState == BluetoothDevice.BOND_NONE || bondState == BluetoothDevice.BOND_BONDING) {
String pinString = settings.getString("com.hiqautomation.iopener.pin", null);
byte[] pinBytes = pinString.getBytes();
btDevice.setPin(pinBytes);
}
}
}
};
Did you have any luck with this? I have done the same thing...the below should help....
Method m = bt_device.getClass().getMethod("cancelBondProcess", (Class[]) null);
m.invoke(bt_device, (Object[]) null);
Out of interest, how did you hide the Soft Keyboard when entering the pin. This is the issue im currently playing with at Android - How to disable Soft Keyboard during Bluetooth Pairing
Mat
这篇关于我如何在共进晚餐的Android preSS蓝牙配对请求对话框(API 19)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!