Aerogear Guides Tutorials to help get you off and running.

AeroGear Android Pagination

The Android AeroGear libraries implement paging as defined in the pagination spec. We also have common use cases for the basic tasks in the Android sections of the paging usage document.

These two resources should be enough to get you up and running with Aerogear controller based services. However, if you have special requirements or legacy services AeroGear's pagination framework can also be extended to support some pretty gnarly use cases.

AeroGear ships with support for selecting data from the server response and using that data as a relative URI for locations of the "next" and "previous" pages of data. You can enable paging by configuring a PageConfig object and setting it on the Pipe using PipeConfiguration.pageConfig. When this option is enabled, and Pipe.readWithFilter will pass PagedList instances to Callback.onSuccess instead of plain Lists. You can call and PagedList.previous for load the next and previous data sets respectively.

Let's say we have a service which returns a page of data in the following format:

    "data": {
        "after": "?after=t3",
        "before": ?before=t1,
        "children": [

The 'after' parameter defines the page of data which comes after the current page. The 'before' parameter likewise defines the page which comes before the page of data. If these fields are relative URIs, AeroGear can use them for paging data.

The PageConfig object has parameters for setting WHERE paging location data is (pageConfig.setMetadataLocation), and which fields correspond to which data pageConfig.setNextIdentifier, pageConfig.setPreviousIdentifier, and several other parameters specified in the JavaDoc.
void onCreate() {
     pipeline = new Pipeline(BASE_URL);

     PageConfig pageConfig = new PageConfig();

     MarshallingConfig marshallingConfig = new MarshallingConfig();

     ResponseParser responseParser = new GsonResponseParser();

     RestfulPipeConfiguration config = PipeManager.config("listing", RestfulPipeConfiguration.class)

     Pipe<Data> pipe = config.forClass(Data.class);


And now when we call read or readWithFilter our CallBack's onSuccess method will be passed a PagedList instance.
public class ReadCallback extends AbstractActivityCallback<List<Data>> {
    public void onSuccess(List<Data> data) {
        ExampleActivity activity = getActivity();
        activity.setData((PagedList<Data>) data);
        activity.setListAdapter(new ArrayAdapter<Data>(activity,

    public void onFailure(Exception e) {
	//Handle error

PagedList has next and previous methods. Both of these methods consume a Callback and call Pipe.readWithFilter with a ReadFilter object designed to reference the particular page requested and the callback provided to the method on PagedList

    public void nextPressed(View button) {;

    public void previousPressed(View button) {