Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Mobile app showing the AeroGear Pipe feature on Android

Author: Daniel Passos (dpassos) Level: Beginner Technologies: Java, Android Summary: A basic example of Pipe Source:

What is it?

The Chuck Norris Jokes project demonstrates how to include retrive data from a REST endpoint

When the application is deployed to an Android device, the application will retrieve a Chuck Norris joke

How do I run it?

System Requirements

Build Application

$ cd /path/to/app
$ ./gradlew clean build

Running the app

To deploy, run and debug the application on an Android device attached to your system, on the command line enter the following:

  1. Install generated apk to device

    $ cd /path/to/app
    $ ./gradlew installDebug
  2. Open app on device

How does it work?

ChuckNorrisJokesApplication is invoked when open the application. The Application life cycle onCreate is called creating a Pipe instance.

ResponseParser responseParser = new GsonResponseParser();

PipeManager.config("chuckNorris", RestfulPipeConfiguration.class)
        .withUrl(new URL(""))

After that ChuckNorrisJokesActivity is invoked. The Activity life cycle onCreate is called first invoking the retrieveJoke method — attempting to retrive the joke from a REST endpoint.

LoaderPipe<Joke> pipe = application.getPipe(this);
pipe.reset(); AbstractActivityCallback<List<Joke>>() {
    public void onSuccess(List<Joke> jokes) {
        // Show the Joke

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