Beacon Event Lifecycle Handler
class BeaconEventLifecycleHandler(onOpenedListener: BeaconOnOpenedListener?, onClosedListener: BeaconOnClosedListener?) : Application.ActivityLifecycleCallbacks
Lifecycle handler for tracking Beacon open and close events.
Register this handler with your Application's ActivityLifecycleCallbacks to receive notifications when the Beacon is opened or closed.
Example usage (Java):
BeaconEventLifecycleHandler eventLifecycleHandler =
new BeaconEventLifecycleHandler(
new BeaconOnOpenedListener() {
@Override
public void onOpened() {
// Handle Beacon opened event
}
},
new BeaconOnClosedListener() {
@Override
public void onClosed() {
// Handle Beacon closed event
}
}
);
registerActivityLifecycleCallbacks(eventLifecycleHandler);Content copied to clipboard
To unregister:
unregisterActivityLifecycleCallbacks(eventLifecycleHandler);Content copied to clipboard
Parameters
on Opened Listener
Listener to be called when Beacon is opened (can be null)
on Closed Listener
Listener to be called when Beacon is closed (can be null)