I am trying to make listview with available bluetooth devices. I trying to use arrayAdapter. I have made string array, but I can't add anything to this array with my code:
String[] values;
private final BroadcastReceiver mReceiver = 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 address to an array adapter to show in a ListView
values.add(device.getName() + "\n" + device.getAddress());
}
}
};
Android studio says that it cant resolve method add
and markups it.
The whole code:
How to fix this and make this work?
Thanks.