Search code examples
androidsocketscan

Unable to get socket scan api to work with oreo 8.1


if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
    // Do this for phones running an SDK before lollipop
    _hostBluetoothAddress = bluetoothAdapter.getAddress();
} else {
    _hostBluetoothAddress = Settings.Secure.getString(getContentResolver(), "bluetooth_address");
}

Using this Code (used in the socket sample EZPairActivity) _hostBluetoothAddress is always returned as null in Android 8.1 (27). I tried using the ANDROID_ID instead but that doesn't seem to work either. Not able to pair a CHS 8Ci to my Pixel XL.


Solution

  • We'll, after talking to Socket mobile I got an answer. Depends on the model. For the model series 8 or 800 I have the user enter the host address manually. The EZPairActivity uses that address just as it would by obtaining it programmatically and it works fine after that. I would recommend storing the host address in a preference or setting that can be retrieved so that the user doesn't have to re-enter it every time.