スレ立てるまでもない質問はここで 140匹目 [転載禁止]©5ch.io
■ このスレッドは過去ログ倉庫に格納されています
0003デフォルトの名無しさん
2015/01/23(金) 15:38:01.99ID:RRRw/PaX自動でのペアリングをsetPinとcreateBondを使って行いたいと考えています。
以下の様に記述してみましたがうまくいきません。
どうすればいいでしょうか。
エラーは
The Method createBond() in the type BluetoothDevice is not applicable for the arguments()
The method convertPinToBytes(String) is undefined for the type BluetoothDevice
とでています。以下、ソースです。
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(TAG, "Action:" + action);
if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
Log.d(TAG, "ACTION_BOND_STATE_CHANGED");
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Method createBond = device.getClass().getMethod("createBond", new Class[] {});
boolean a = device.createBond(wifiInfo.getMacAddress());
boolean b = device.setPin(device.getAddress(), BluetoothDevice.convertPinToBytes("0000"));
Log.d(TAG, "createBond:" + a + ", setPin:" + b);
if (a && b) {
Log.d(TAG, "AutoPairing Success !");
}
}
■ このスレッドは過去ログ倉庫に格納されています