5 Replies Latest reply on Dec 11, 2018 7:11 AM by Darryn Campbell

    Programmatically Obtain the Bluetooth MAC Address in Android Oreo Version

    Eduardo Rubio Rey

      Hi community,

       

      We connect the external scanners to the devices in SPP mode. We are doing tests with a terminal TC51 with Android Oreo (8.1) and I am not able to find how to obtain the MAC address of the Bluetooth, programmatically. With versions of Android before Oreo, we know how to do it, but this functionality has changed with Oreo, someone knows how to get it?

       

      Thank you

        • Re: Programmatically Obtain the Bluetooth MAC Address in Android Oreo Version
          Dmitry Prokhorov

          Hello Eduardo,

           

          As you can see here Android 6.0 Changes  |  Android Developers

           

          Programmatic access to to MAC addresses has been removed starting from Android 6.0:

          "To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00"

           

          Dmitry Prokhorov

          Software Engineer, Kutir Mobility

          Posted on behalf of Zebra Technologies

            • Re: Programmatically Obtain the Bluetooth MAC Address in Android Oreo Version
              Eduardo Rubio Rey

              As you probably know, there were tricks to get this value, despite the fact that this security limitation was established in version 6. This alternative way worked until Oreo 8.0. However, Oreo 8.1 has been blocked.

               

               

              I understand that data protection is important, but the great majority of Zebra devices are oriented to the industrial environment, not for consumer. For software developers, who work to offer simple applications to users, this type of data is fundamental.

               

              Thanks for you annswer.

                • Re: Programmatically Obtain the Bluetooth MAC Address in Android Oreo Version
                  Darryn Campbell

                  Hi Eduardo.  Why do you need to know the MAC address of the Android device when you are connecting to an SPP Bluetooth scanner, wouldn't you just need the MAC address of the scanner so you can connect to it (where the scanner is acting as the BT slave).  Sorry if I'm not understanding something here.

                    • Re: Programmatically Obtain the Bluetooth MAC Address in Android Oreo Version
                      Eduardo Rubio Rey

                      Hi Darryn,

                       

                      Sorry for my delay in response.

                       

                      I will try to explain the problem and why we need to access the Bluetooth MAC ADDRESS.

                       

                      We develop applications for one of the largest integrators in France. We have numerous customers that work with Windows CE / Mobile terminals that use, at the same time, the internal scanner and an external scanner (wired or BT) depending on the operations that the user has to perform.

                       

                      Now we are developing the same solutions in Android environment (migration). And customers want to keep their way of working, with two scanners simultaneously.

                       

                      We consulted with Zebra support to be able to implement this way of working and they informed us that: we can only have one scanner connected at a time using the EMDK and SSI. OK, then the solution is that the Internal Scanner will be using SSI and the BT scanner (RS507, for example) via SPP.

                       

                      Knowing that we need to connect the external scanner in SPP mode, we need the MAC ADDRESS to be able to create the barcode, which allows users to easily pair the BT scanner. The same case as performing the Bluetooth Pairing Utility for SSI mode.

                       

                      I hope my explanation complements my initial question. Thank you.