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幫助會很大。
您是否先將設備與手機配對? – SeahawksRdaBest
Nopes.I有單獨的代碼來顯示配對的設備。 – kgandroid
不,我的意思是你去了設置(在Android設備上的接收器/發射器端),找到你想配對的設備,完成確認,然後運行你的應用。由於明顯的擔憂,藍牙對安全協議很感興趣。 – SeahawksRdaBest