In an answer to another question, I saw that "You can also transmit as a beacon on rooted Android 4.4.3 devices, but it requires an app installed with system privileges."
How can this be done?
In an answer to another question, I saw that "You can also transmit as a beacon on rooted Android 4.4.3 devices, but it requires an app installed with system privileges."
How can this be done?
Yes, this is possible on 4.4.3, but the critical API methods
startAdvertising()
,stopAdvertising()
andgetAdvScanData()
(which allows you to read and write the raw information sent out in the advertisement) are blocked from use unless an app hasandroid.permission.BLUETOOTH_PRIVILEGED
. This is a system-level permission, so the only way to get this is for your custom app is to root your phone, and install your app in the /system/priv-app directory.If you can accomplish that, the basic code to do this is:
The above code shows you how to transmit an open source AltBeacon. But you can transmit other beacon types by changing the byte pattern.
Another important restriction in Android 4.4 is that a bug prevents you from advertising more than 24 bytes of data, instead of the 26 that should be allowed. This means that beacon advertisements may be truncated if they require more than 24 bytes. AltBeacon, for example, uses the second of those last two bytes to store the calibrated transmitter power. Because this cannot be sent, that means distance estimates are not possible using the Android Beacon Library's standard APIs.
You can see a description of how this is done here