In this example we will construct a simple Android Activity that listens for NEON location updates and then prints those updates to the console. Note that the NEON API provides helpful
toString() methods on data objects to aid in development.
We will start by creating a new Activity that implements the
INeonLocationListener interface. This interface can be implemented by an activity or any other class in order to receive location updates.
public class MainActivity
public void onLocationChanged(DeviceLocation location)
Next we need to register the
INeonLocationListener instance with the NEON API. The NEON API contains the class
Neon with several static methods which provide a simple way to configure the NEON API. In the example below we override the
onCreate method and register our listener with NEON for location updates.
protected void onCreate(Bundle savedInstanceState)
Internally, the NEON API utilizes Android Binders to handle communication between the end user application and the NEON Location Service. When using the NEON API, the developer is responsible for binding and unbinding the NEON Location Service. Note that the NEON Location Service will not be running unless it is bound and must remain bound throughout the time that location updates are desired. In the example below we bind the NEON Location Service in the
onStart method and unbind in the
protected void onStart()
protected void onStop()