beacons-android
beacons-android copied to clipboard
Is it UTF8 encoded or base 64?
I am using to publish iBeacons, But i don't know in what format this library encodes it. While I am trying to scan it by Google NearBy, I am not able to read it. As Google NearBy Doc Says.
mMessageListener = new MessageListener() {
@Override
public void onFound(Message message) {
// Do something with the message here.
Log.i(TAG, "Message found: " + message);
Log.i(TAG, "Message string: " + new String(message.getContent()));
Log.i(TAG, "Message namespaced type: " + message.getNamespace() +
"/" + message.getType());
}
...
};
Parsing the content depends on the format of the bytes. This example assumes that the content bytes encode a UTF-8 string, but your beacon message can encode other byte formats (for example a serialized protocol buffer)
So when I am trying to Log the above method provided by Google Nearby Messages API.
UTF-8 is a string encoding (and the default one in Android's Java). iBeacon is a binary format (16 bytes UUID + 4 bytes major/minor + 1 byte TX ref power), plus the extra Manufacturer Data overhead. Why on earth would you want to try and convert a random binary buffer to a UTF-8 String? It might even throw exceptions if invalid code points get detected,
Thanks, It worked 😝