Beispiel #1
0
  @SuppressWarnings("deprecation")
  @Override
  public void onResume() {
    super.onResume();

    bluetoothTask.init();

    showDialog(DEVICES_DIALOG);
  }
Beispiel #2
0
  public Dialog createDevicesDialog() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setTitle("Select device");

    Set<BluetoothDevice> pairedDevices = bluetoothTask.getPairedDevices();
    final BluetoothDevice[] devices = pairedDevices.toArray(new BluetoothDevice[0]);
    String[] items = new String[devices.length];
    for (int i = 0; i < devices.length; i++) {
      items[i] = devices[i].getName();
    }

    alertDialogBuilder.setItems(
        items,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

            bluetoothTask.doConnect(devices[which]);
          }
        });
    alertDialogBuilder.setCancelable(false);
    return alertDialogBuilder.create();
  }
Beispiel #3
0
 @Override
 protected void onDestroy() {
   bluetoothTask.doClose();
   super.onDestroy();
 }