I\'m trying to create an image button that, when pressed, presents the users a list of Paired Bluetooth devices to connect to.
However, I get \"Set cannot be resolve
Hi, You can also try this code where you just have get the Set of bonded devices.
private ArrayAdapter bondedAdapter = null;
private ListView listViewPairedDevices = null;
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
try {
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
listViewPairedDevices = (ListView) findViewById(R.id.listViewPairedDevices);
bondedAdapter = new ArrayAdapter(this, R.layout.lyt_scanlist_textview);
Set bondedSet = bluetoothAdapter.getBondedDevices();
Log.v(BluetoothDemoActivity.LOG, "BluetoothDemo : bondedSet: "+bondedSet);
int count = 0;
if(bondedSet.size() > 0){
for(BluetoothDevice device : bondedSet){
textViewPairedDevice.setVisibility(View.VISIBLE);
bondedAdapter.add(device.getName()+"\n"+device.getAddress());
Log.v(BluetoothDemoActivity.LOG, " count = "+count++);
}
}else{
bondedAdapter.add("No Devices");
}
listViewPairedDevices.setAdapter(bondedAdapter);
} catch (Exception e) {
// TODO Auto-generated catch block
Log.e(BluetoothDemoActivity.LOG, e.toString(),e.fillInStackTrace());
}
}//onStart ends