Location & Events

Register for Location and Events

To receive locations or events from the NEON Location Service, you need to implement the INeonLocationListener and INeonEventListener interfaces in your main activity.

TIP: After adding the interfaces to the class definition, you can click on the light bulb icon as shown below to have Android Studio automatically implement the required methods.

Listeners

This will create two functions, onEvent() and onLocationChanged(). We will populate these functions in later sections.

@Override
public void onEvent(NeonEventType type, INeonEvent event) {

}

@Override
public void onLocationChanged(NeonLocation location) {

}

In order to register your INeonLocationListener and INeonEventListener with the NEON API, use the following code:

Neon.registerLocationUpdates(this);
Neon.registerEvents(this);

This code only needs to be called once on creation. On shutdown, you should unregister with the following code:

Neon.unregisterLocationUpdates(this);
Neon.unregisterEvents(this);