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

Basic Mobile Application client to AeroDoc backend

Author: Daniel Passos (dpassos)
Level: Beginner
Technologies: Java, Android
Summary: A client of AeroDoc backend
Target Product: -
Product Versions: -

What is it?

AeroDoc project demonstrates how to integrate to a backend using Pipe, Auth, Store and Push functionality in Android applications.

How do I run it?

System Requirements


The project source code must be customized with the unique metadata assigned to the application variant by the AeroGear UnifiedPush Server and FCM and AeroDoc URL.

  1. Open /path/to/AeroDoc/app/src/main/java/org/jboss/aerogear/android/cookbook/aerodoc/ for editing.
  2. Enter the application variant values allocated by the AeroGear of UnifiedPush Server and GCM for the following constants:

    private static final String BASE_BACKEND_URL = "";
    private static final String UNIFIED_PUSH_URL = "";
    private static final String GCM_SENDER_ID = "";
    private static final String VARIANT_ID = "";
    private static final String SECRET = "";
  3. Save the file.

Build Application

$ cd /path/to/AeroDoc/
$ ./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/AeroDoc
    $ ./gradlew installDebug
  2. Open app on device

How does it work?

AeroDocApplication is invoked when open the application. The Application life cycle onCreate is called creating and AuthenticationModule, two pipes and a local Store.

public void onCreate() {


private void configureBackendAuthentication() {

    try {

        final URL serverURL = new URL(BASE_BACKEND_URL);

                        new AeroDocAuthenticationConfigurationProvider());

        authenticationModule = AuthenticationManager
                .config("AeroDocAuth", AeroDocAuthenticationConfiguration.class)

    } catch (MalformedURLException e) {
        throw new RuntimeException(e);


private void createApplicationPipes() {

    try {

        final URL serverURL = new URL(BASE_BACKEND_URL);

        PipeManager.config("lead", RestfulPipeConfiguration.class)
                .withUrl(UrlUtils.appendToBaseURL(serverURL, "/rest/leads"))

        PipeManager.config("agent", RestfulPipeConfiguration.class)
                .withUrl(UrlUtils.appendToBaseURL(serverURL, "/rest/saleagents"))

    } catch (MalformedURLException e) {
        throw new RuntimeException(e);


private void createLocalStorage() {

    DataManager.config("lead", SQLStoreConfiguration.class)

    localStore = (SQLStore) DataManager.getStore("lead");


After login the LoginActivity will register device on push server

public void registerDeviceOnPushServer(String alias) {

    try {

        RegistrarManager.config("AeroDoc", AeroGearGCMPushConfiguration.class)
                .setPushServerURI(new URI(UNIFIED_PUSH_URL))

        PushRegistrar registrar = RegistrarManager.getRegistrar("AeroDoc");
        registrar.register(getApplicationContext(), new Callback<Void>() {
            public void onSuccess(Void data) {

            public void onFailure(Exception e) {
                Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();

    } catch (URISyntaxException e) {
        throw new RuntimeException(e);