2014-06-05 37 views
0

我正在實施一個應用程序bluetooth.Here我面臨一個奇怪的問題。我想顯示所有可用的設備時,我掃描我的bluetooth.But我的應用程序只是發現藍牙的pc手機或製表符.The藍牙不showing.To實現藍牙功能我用this tutorial.Here是找到的藍牙設備代碼:奇怪的行爲與藍牙發現

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));  
     }  
    } 

我已搜查谷歌,但沒有發現任何solution.Any幫助會很大。

+0

您是否先將設備與手機配對? – SeahawksRdaBest

+0

Nopes.I有單獨的代碼來顯示配對的設備。 – kgandroid

+1

不,我的意思是你去了設置(在Android設備上的接收器/發射器端),找到你想配對的設備,完成確認,然後運行你的應用。由於明顯的擔憂,藍牙對安全協議很感興趣。 – SeahawksRdaBest

回答

1

首先確保在其他設備上啓用了藍牙。然後讓其他設備可以發現。在藍牙菜單中應該有一個選項可以使設備可以被發現。該設備只能暫時發現(通常約2分鐘)。

+0

我的應用符合上面提到的所有標準 – kgandroid