Flutter Android

Add new app into Appfigurate Emulator

Run Appfigurate in the Android Emulator.

Tap Add app.

Select app type Android.

Enter a URL scheme that will be used by Appfigurate to launch your app in order to read or apply configuration. The URL scheme must be 4-64 ASCII characters in length and must be unique to your app. e.g. YOUR-APP-URLSCHEME

Tap Add app.

Output source code snippets

In Appfigurate Emulator app, under the KOTLIN/ANDROID LIBRARY INTEGRATION section:

Tap Output implementation then tap Console.

The output will be displayed in Android Studio, under the Logcat tab. Filter the output to application nz.co.electricbolt.appfigurate

Create nz.co.electricbolt.appfiguratelibrary.Configuration subclass

In Android Studio/IntelliJ, add a Kotlin class called Configuration.kt

Paste the Kotlin implementation file output to the Console in the section Output source code snippets above.

Note: your public key output to the Console in the section Output source code snippets above will be different to the public key in the following example.

Kotlin Configuration example

package com.yourcompany.yourapp

import nz.co.electricbolt.appfiguratelibrary.annotations.*

public class Configuration extends nz.co.electricbolt.appfiguratelibrary.Configuration {

    @BooleanProperty(description = "Log debug output to console", restart = false)
    var debugLogging = false

    @StringPropertyListEdit(regularExpression = "https://[\\w\\.-]+\\.yourappserver.com/.*",
        description = "Application server url", restart = false, keys = {"Dev", "Prod"},
        values = {"https://dev.yourappserver.com/api", "https://www.yourappserver.com/api"})
    var String? serverURL = null

    override fun allowInvalidSignatures(): Boolean {
        return BuildConfig.DEBUG
    }

    override fun publicKey(): String {
        // 41 36 87 71 0D 05
        return """-----BEGIN PUBLIC KEY-----\n
            MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4TZnKfGeXttN7Rr3eiAZ\n
            ...
            ywIDAQAB\n
            -----END PUBLIC KEY-----\n
            """.trimIndent()
    }

    override fun reset() {
        debugLogging = true
        serverURL = "https://www.yourappserver.com/api"
    }

}

Edit AndroidManifest.xml

In your apps AndroidManifest.xml file include the following meta-data and provider sections inside your application section. Replace the text YOUR-APP-URLSCHEME with your own app's URL Scheme - the same value you added in the section Add new app into Appfigurate Emulator above.

AndroidManifest.xml example

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools" package="com.yourcompany.yourapp">

    <application
        ...

        <meta-data
            android:name="APLConfigurationSubclass"
            android:value=".Configuration"/>
        <provider
            android:authorities="YOUR-APP-URLSCHEME"
            android:name="nz.co.electricbolt.appfiguratelibrary.CommandContentProvider"
            android:exported="true">
        </provider>
...        

Test your Android app

To test that you've successfully updated your app to use Appfigurate:

  • Compile and run your app to the Emulator instance.

  • Launch the Appfigurate Emulator app.

  • Tap your applications row. The app's configuration will be read in the background.

  • Appfigurate's Configure app screen will now be displayed. You can now change the debugLogging and serverURL properties. Tap Apply⌄ to apply the configuration to your watchOS app.

Now jump to Supported property types.

Last updated