I am working in Android Studio and trying to compile some existing code, but I get an "incompatible type" (object required) error for variable BluetoothDevice
at this line, though I have the import line at the top of the code:
import android.bluetooth.BluetoothDevice;
/* other code */
for(BluetoothDevice bt : pairedDevices)
Here is the function with the line of interest:
public void pairedDevicesList() {
pairedDevices = myBluetooth.getBondedDevices();
ArrayList list = new ArrayList();
if (pairedDevices.size() > 0) {
for(BluetoothDevice bt : pairedDevices) {
list.add(bt.getName() + "\n" + bt.getAddress()); //Get the device's name and the address}
}
} else {
Toast.makeText(getApplicationContext(), "No Paired Bluetooth Devices Found.", Toast.LENGTH_LONG).show();
}
final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, list);
devicelist.setAdapter(adapter);
devicelist.setOnItemClickListener(myListClickListener); //Method called when the device from the list is clicked
}
Any ideas? Thanks