HERE Android SDK Developer's Guide

Next Nearby Departures

You can use the HERE SDK to query for the next transit departures for a particular station. Next nearby departure information is based on the timetable information provided by transit agencies, and it includes all types and times of departures from one station at a given time.

Note: Next Nearby Departures and All Next Departures are currently offered as beta features. APIs may change without notice.
Figure 1. Station Departures

To query for the departures, create a request by using the stationId and stationCoordinates and implement a ResponseListener. The returned DepartureBoard contains a list of Departure objects that is sorted by the departure times.

// ID of a station, can be obtained from station search
String stationId = "717010002";
// Geocoordinate of a station
GeoCoordinate stationCoordinates = new GeoCoordinate(40.750488, -73.993546);  //somewhere in NY

// listener that will be notified after request is completed
RequestManager.ResponseListener<DepartureBoard> responseListener = new RequestManager.ResponseListener<DepartureBoard>() {

  @Override 
  public void onSuccess(DepartureBoard departureBoard) {
    List<Departure> departures = departureBoard.getDepartures();
    for (Departure departure : departures) {
      Station station = departure.getStation();
      Date departureTime = departure.getTime();
      Transport line = departure.getTransport();
      String direction = departure.getTransport().getDirection();
      // ...
    }
  }

  @Override public void onError(ErrorCode errorCode, String errorMessage) {
    // Handle error
  }
};

// creating and executing the request
DepartureBoardRequest request = new RequestManager().createDepartureBoardRequest(
    stationCoordinates, stationId, responseListener);
request.execute();

All Next Departures

To query for departure information of stations in a given area, create a request by using the coordinates and implement a ResponseListener. The returned MultiBoardResult contains a list of StationWithDepartureBoard objects that contain departure information, which are sorted by the departure times. StationWithDepartureBoard is a child implementation of the Station class.

// Geocoordinate of a reference point
GeoCoordinate coordinates = new GeoCoordinate(40.750488, -73.993546);  //somewhere in NY

// listener that will be notified after request is completed
RequestManager.ResponseListener<MultiBoardResult> responseListener = new RequestManager.ResponseListener<MultiBoardResult>() {

  @Override
  public void onSuccess(MultiBoardResult multiBoard) {
    Collection<StationWithDepartureBoard> stations = multiBoard.getStations();
    Collection<Transport> transports = multiBoard.getTransports();  
    for (StationWithDepartureBoard station: stations) {
      String stationName = station.getAddress().getName();
      List<Departure> departures = station.getDepartureBoard().getDepartures();
      for (Departure departure : departures) {
        Date departureTime = departure.getTime();
        Transport transport = departure.getTransport();
        String direction = departure.getTransport().getDirection();
        // etc.
      }
    }
  }

  @Override public void onError(ErrorCode errorCode, String errorMessage) {
    // Handle error
  }
};

// creating and executing the request
MultiBoardRequest requestNearby = new RequestManager().createMultiBoardRequest(
  coordinates, responseListener);
  
// You can set other search parameters here before calling execute()  
requestNearby.execute();

You can call requestNearby.setRadius(int) to limit the search area before executing the search. You can also limit the search to specific stations by using an overloaded createMultiboardRequest.