National Parks - Android

Setup

  1. A "Global" gradle.properties file is needed to supply the necessary configuration items needed to build the Android application. This file is typically located in the user's HOME directory under a directory named .gradle. Start by creating this directory if it doesn't exist:

    $ mkdir $HOME/.gradle
  2. Create the $HOME/.gradle/gradle.properties file with the following content:

    RUM_ACCESS_TOKEN=<token>
    RUM_REALM=<realm>
    REST_BACKEND=<backend_url>

    where:

  3. To set up this project, first clone the repository

    $ git clone https://github.com/billmeyer/nationalparks-android.git
  4. Build the project into an APK file.

    $ cd nationalparks-android
    $ ./gradlew assemble

Run

  1. Open the project in Android Studio and run on a physical device or emulator.

Evaluate

  1. The application starts with creation of an instance of NationalParksApplication in which the onCreate() method initializes the Splunk Observability RUM module:

      Config config = Config.builder()
              .applicationName("National Parks")
              .rumAccessToken(BuildConfig.RUM_ACCESS_TOKEN)
              .realm(BuildConfig.RUM_REALM)
              .deploymentEnvironment("development")
              .debugEnabled(true)
              .build();
      SplunkRum.initialize(config, this);
    
      SplunkRum sr = SplunkRum.getInstance();

    The BuildConfig.RUM_ACCESS_TOKEN and BuildConfig.RUM_REALM are provided by the configuration done on step 2 from the Setup section above.

  2. The app consists of two Fragments:

    • HealthCheckFragment- calls the Health Check endpoint (/api/v1/health-check) to confirm it's up. If so, the response "API is up and running" is returned from the Health Check endpoint and displayed in the center of the Fragment.

    Health Check Fragment

    • NationalParksFragment- calls the National Parks endpoint (/api/v1/nationalparks) to fetch a random set of National Parks. Each time the Fragment displayed, a new random set will be retrieved.

    National Parks Fragment