You need Android Studio installed. These instructions are based on version 2.2.

Prerequisites

Before beginning make sure you have Realm Object Server running either locally on your Mac or via the Linux install.

If you haven’t already downloaded the demo app via the macOS bundle, do so. Even if you’re not on a Mac, it includes the source code for RealmTasks Android.

Open RealmTasks

Open Android Studio and choose Open an existing Android Studio Project:

Android Studio

Navigate to the containing folder of the unzipped bundle then open: /realm-mobile-platform/demo/RealmTasks/RealmTasks Android:

Open RealmTasks in Android Studio

Build and Run RealmTasks

Before building RealmTasks, you must ensure the application is configured to connect to Realm Object Server on the correct IP address.

By default, in RealmTasksApplication.java your local IP address is used via a build configuration step:

public class RealmTasksApplication extends Application {

    public static final String AUTH_URL = "http://" + BuildConfig.OBJECT_SERVER_IP + ":9080/auth";
    public static final String REALM_URL = "realm://" + BuildConfig.OBJECT_SERVER_IP + ":9080/~/realmtasks";

    ...
}

If you have the Realm Object Server running locally, you can build and run as is.

However, if you installed Realm Object Server for Linux on another machine, you will need to adjust the default IP address to point to your server address.

With the correct IP address in place, click Run in the file menu and then Run 'app' to build and run on either an Android emulator or device.

Using the App

On first launch, you will need to register a username and password by clicking Register in the top right hand corner. Choose a username and password, then click Register to continue.

Congrats! You are now in the default task list for the application.

You can enter new tasks by slowly dragging downward until a new Task entry appears. Any entries you create will be instantly synchronized by the Realm Object Server and appear on other devices, or in the macOS or iOS versions as well.

RealmTasks for Android

Swiping left or right on items in the task list in the application will delete or mark items as “done.” Here too, these changes will be immediately reflected in the other version of the application.

Observing Changes In Realm Browser

The Realm Browser showing synced data

If you are using a Mac, you can use the Realm Browser to explore and interact with synchronized Realm data in realtime.

Open the macOS app named “Realm Browser” inside the “realm-mobile-platform” folder.

The app will open a panel with initial options. Click “Connect to Object Server”.

Using the Realm Browser to connect to the Realm Object Server

In the “Connect to Object Server” dialog box, enter realm://127.0.0.1:9080 as the server URL.

In order to connect as admin we need an admin access token. In the terminal running the server, look for a line starting with Your admin access token is:. Copy the long hexadecimal string, including the two trailing equals signs (==). This is the admin access token for your Object Server.

If you are running Realm Object Server on Linux, your admin token was automatically generated and can be retrieved by:

cat /etc/realm/admin_token.base64

A new dialog box will open, listing all the Realms on your server. If you only registered one user, there will be only one Realm. Select it to view the contents.

If you still have the RealmTasks app open, you can now try editing and reordering your tasks while seeing the changes live in the browser. Changes in the browser are reflected instantly in the app as well.

What’s Next?

Learn more about the Realm Mobile Platform by exploring the documentation: