2014-06-05 2 views
0

블루투스로 앱을 구현하고 있습니다. 이상한 문제가 있습니다. 내 블루투스를 스캔 할 때 사용 가능한 모든 기기를 보여주고 싶습니다.하지만 내 앱은 블루투스 만 발견하고 있습니다. 나는 구글을 검색 한하지만 어떤 solution.Any를 찾을 수 없습니다블루투스 검색으로 이상한 동작이 발생했습니다.

final BroadcastReceiver bReceiver = new BroadcastReceiver() { 
     public void onReceive(Context context, Intent intent) { 
      String action = intent.getAction(); 
      // When discovery finds a device 
      if (BluetoothDevice.ACTION_FOUND.equals(action)) { 
       // Get the BluetoothDevice object from the Intent 
       BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 
       // add the name and the MAC address of the object to the arrayAdapter 
       BTArrayAdapter.add(device.getName() + "\n" + device.getAddress()); 
       BTArrayAdapter.notifyDataSetChanged(); 
      } 
     } 
    }; 

    public void find(View view) { 
     if (myBluetoothAdapter.isDiscovering()) { 
      // the button is pressed when it discovers, so cancel the discovery 
      myBluetoothAdapter.cancelDiscovery(); 
     } 
     else { 
      BTArrayAdapter.clear(); 
      myBluetoothAdapter.startDiscovery(); 

      registerReceiver(bReceiver, new IntentFilter(BluetoothDevice.ACTION_FOUND));  
     }  
    } 

: 휴대 전화 또는 탭의 국지적 인 블루투스 내가 tutorial.Here 블루투스 장치를 찾을 수있는 코드 this을 사용하고 블루투스 기능을 구현 showing.To되지 않습니다 도움이 될 것입니다.

+0

기기를 휴대 전화와 페어링 해 보셨습니까? – SeahawksRdaBest

+0

Nopes. 페어링 된 장치를 표시하는 별도의 코드가 있습니다. – kgandroid

+1

아니요. 안드로이드 기기에서 수신자/송신기 쪽 모두 설정으로 갔다가 페어링하려는 기기를 찾은 다음 확인을 완료 한 후 앱을 실행했습니다. 블루투스는 명백한 우려로 인해 보안 프로토콜에 까다 롭습니다. – SeahawksRdaBest

답변

1

먼저 다른 장치에서 Bluetooth가 활성화되어 있는지 확인하십시오. 그런 다음 다른 장치를 검색 가능하게 만듭니다. 블루투스 메뉴에 장치를 검색 가능하게하는 옵션이 있어야합니다. 장치는 일시적으로 만 검색 할 수 있습니다 (일반적으로 약 2 분).

+0

내 앱이 위에서 언급 한 모든 기준을 충족합니다. – kgandroid

관련 문제