0
votes

I have an application which connects to a bluetooth device, opens an input/outputstream and a socket and functions as some kind of "chat" between these two devices. The chat part and connection and everything is done.

However I've run into quite a wall here, I need to add an option so that when the app connects to a bluetooth device it gives you the option to save it as the default bluetooth device, so when you first open the app, if the default device is in range it automatically connects to it (the device is already paired).

So basically what I need is: We connect to a (already paired) bluetooth device, we answer yes to saving it as a default device and now whenever the app is opened it should automatically look for and connect to this device if it is in range.

1

1 Answers

0
votes

info from: http://developer.android.com/guide/topics/connectivity/bluetooth.html

 Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
 // If there are paired devices
      if (pairedDevices.size() > 0) {
     // Loop through paired devices
     for (BluetoothDevice device : pairedDevices) {
    // Add the name and address to an array adapter to show in a ListView
         mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
     }
 }