2014-07-22 4 views
0

블루투스 페어링 요청을 수신 했으므로 확인 버튼 만 누르면됩니다. 나는 코드로 이것을하고 싶다. 어떻게해야합니까? ACTION_BOND_STATE_CHANGED 이벤트에서이를 만들 수 있습니까?ok 버튼을 클릭하면 시뮬레이트됩니다. android

.performClick()을 사용해야하는 경우 페어링 블루투스 대화 상자에서 확인 버튼에 대한 참조를 얻으려면 어떻게해야합니까?

은 지금까지 나는 onReceive 기능에 방송 수신기이 있습니다

if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) { 
      int prevBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, -1); 
      int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1); 
      BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 

      Log.i(TAG, "bond state changed"); 
      Log.i(TAG, "device:" + device.getName()); 
      Log.i(TAG, "prev state:" + prevBondState); 
      Log.i(TAG, "curr state:" + bondState); 
      if (prevBondState == BluetoothDevice.BOND_BONDING) { 

       if (bondState == BluetoothDevice.BOND_BONDED) { 
        Globals.sendStatus("bluetooth", device.getName() + " pairing successful"); 
        Log.i(TAG, device.getName() + " pairing successful"); 
       } 
      } else if (prevBondState == BluetoothDevice.BOND_BONDED) { 
       if (bondState == BluetoothDevice.BOND_NONE) { 
        Log.i(TAG, device.getName() + " unpairing successful"); 
        Globals.sendStatus("bluetooth", device.getName() + " unpaired"); 
       } 
      } 
     } 

답변

1

당신은 performClick() 메소드를 시도 할 수 있습니다. 버튼과 연결된 onClickListener이 실행됩니다.

myButton.performClick(); 
+0

하지만 어떻게 페어링 요청 대화 상자에서 확인 버튼에 대한 참조를 얻을 수 있습니까? – Iulian932

+0

@ Iulian932 몇 가지 코드를 보여줄 수 있습니까? 그렇다면 내가 생각할 수있는 몇 가지 조치를 제안 할 수 있습니다. 브로드 캐스트 리시버 내에서 이러한 이벤트를 위해 플랫폼에서 제공하는 인터페이스가있을 수 있습니다. –

+0

첫 번째 게시물에 몇 가지 코드를 추가했습니다. – Iulian932

관련 문제