Event API for Android

Follow

Once you have integrated the Beemray service in your Android app, you can send events to Beemray backend using the method save of classcom.beemray.android.sdk.io.net.rest.api.EventAPI. The signature for this method is:

EventAPI.save method signature

/**
 * Saves the given event into the backend and invoked the given listener
 * after the request is finished. Returns the request which is used to
 * access the network. Throws an IOException if any error occurs when
 * accessing the network.
 *
 * @param e an event which will be saved.
 * @param l a listener which is used when the request is processed.
 * @return the request which is used to access the network.
 * @throws IOException if any error occurs when accessing the backend.
 */
final public AbstractHttpRequest save (Event e, ApiListener l) throws IOException;

 

Event sending example

Event event = Event.create("Amazing goal");
event.useStand(); // add current location and nearby beacons info
event.addBoolean("penalty", true);
event.addNumber("playernumber", (double) 10);
event.addString("name", "Leo Messi");
event.addTimeStamp("match_date", new Date());
 
Api.events.save(evt, new ApiListener() {
  @Override
  public void response(HttpURLConnection connection, T data, Throwable t) {
    if(null == t)
      System.out.println("The event was sent");
  }
});
Have more questions? Submit a request

Comments