2016-06-27 7 views
1

인터넷에서 꽤 오래 동안 찾고 있는데, 찾고있는 것을 찾을 수 없습니다.블루투스가 연결되어 있는지 Android가 확인하십시오.

내 앱이 이미 블루투스 기기에 연결되어 있다면 (내 앱을 시작하기 전에 /) 내 앱을 어떻게 찾을 수 있습니까? 내가 거기에 기대했다

는 응용 프로그램 시작에 연결된 장치의 목록을 검색 할 수있는 방법이 없습니다 bool BluetoothAdapter.isPaired();

+0

가능한 중복 [블루투스 장치가 연결되어 있는지 프로그래밍 방식으로 알려주는 방법은 무엇입니까? (안드로이드 2.2)] (http://stackoverflow.com/questions/4715865/how-to-programmatically-tell-if-a-bluetooth-device-is-connected-android-2-2) – Strider

+0

@Strider OK - thx . 그래서 기본적으로 불가능합니다. :( – 000000000000000000000

+0

중복 질문 : 여기에서이 답변을 확인하십시오 : http://stackoverflow.com/a/4716715/5476209 – TapanHP

답변

0

당신이 임의의 블루투스 장치에 연결 당신이 BluetoothAdapter.getProfileConnectionState (프로필)를 사용하여 설정된 경우에만 관심이있는 경우 :의

adapter = BluetoothAdapter.getDefaultAdapter(); 
    if (adapter != null && adapter.isEnabled()) { 
     int[] profiles = {BluetoothProfile.A2DP, BluetoothProfile.HEADSET, BluetoothProfile.HEALTH}; 
     boolean connectionExists = false; 
     for (int profileId : profiles) { 
      if (BluetoothAdapter.getProfileConnectionState(profileId) == 
            BluetoothProfile.STATE_CONNECTED) { 
       connectionExists = true; 
       break; 
      } 
     } 
    } 
관련 문제