Skip to content

Instantly share code, notes, and snippets.

@rohanmendon
Created August 28, 2019 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohanmendon/a3c673859e02c3f33f27e4876265f13c to your computer and use it in GitHub Desktop.
Save rohanmendon/a3c673859e02c3f33f27e4876265f13c to your computer and use it in GitHub Desktop.
Creating an instance of the paired OBDII device
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
private static String OBD2_DEVICE_NAME = "OBDII"; // Name of the Device shipped by the manufacturer
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Set<BluetoothDevice> bondedDevices = mBluetoothAdapter.getBondedDevices();
BluetoothDevice obd2Device;
for(BluetoothDevice bondedDevice: bondedDevices) {
if (bondedDevice.getName().contains(OBD2_DEVICE_NAME)) {
obd2Device = bondedDevice;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment