Как сделать всплывающее окно на Android, чтобы при нажатии на одно из устройств оно сохраняло имя устройства в переменной.Когда я делаю это, ничего не происходит, и мне действительно нужна помощь, чтобы понять это.
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// No bluetooth support on device
}
if (mBluetoothAdapter != null)
{
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
String[] btarray;
List<String> btlist = new ArrayList<String>();
BTArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
// get paired devices
pairedDevices = mBluetoothAdapter.getBondedDevices();
// put it's one to the adapter
for(BluetoothDevice device : pairedDevices) {
btlist.add(device.getAddress());
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
builder.create();
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("BT")
.setItems(btlist2, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
builder.create();
Это не сработало