I can’t figure out how to get my bonded devices on a list through this code :
bt_scan.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
// If there are paired devices
if (pairedDevices.size() > 0) {
// Loop through paired devices
for (BluetoothDevice device : pairedDevices) {
// Add the name and address to an array adapter to show in a ListView
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}
}});}
I don’t know how to get it in a text view or a list view one the same layout or even in another if it’s possible.
I’d like to make a connection to one of the found devices but that’s a whole other story.
(Here is my full code if it helps : http://pastie.org/4582924)
Thanks a lot !
Yes, I agree with Vishwa, the Bluetooth Chat Application is very helpful, I have done same(like yours) kind of development, here is my code,
main.xml
Activity Class
BroadCastReceiver Class
The code will search for the active bluetooth device and display it in the listView.