Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CHLibrarian/db77bcf21f55b8bf7a07 to your computer and use it in GitHub Desktop.
Save CHLibrarian/db77bcf21f55b8bf7a07 to your computer and use it in GitHub Desktop.
ContextHub Element Services Beacon Update (Android)
// Updating a beacon with the name "Beacon 2" and adding the tag "park"
// In order to update a beacon, you need to pass in a valid beacon object
beacon.setName("Beacon 2");
beacon.getTags().add("park");
BeaconProxy proxy = new BeaconProxy();
proxy.updateBeacon(beacon.getId(), beacon, new Callback<Beacon> {
@Override
public void onSuccess(Beacon result) {
// If you do not have push properly set up, you need to explicitly call synchronize on ProximityService so it will generate events for this device
ProximityService.getInstance().synchronize();
Toast.makeText(getActivity(), result.getName(), Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Exception e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment