Flutter Android

Add new app into Appfigurate Emulator.

Run Appfigurate in the Android Emulator.

Tap Add app.

Select app type Android.

Enter the URL scheme quickstart 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.

Tap Add app.

Create nz.co.electricbolt.appfiguratelibrary.Configuration subclass

In your app, add a Kotlin class called Configuration.kt

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

Note: your public key output to the Console in Output source code snippets will be different to the public key in the following 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", "Prod":"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
			PMEPsZvbo7lgIpMh6OjgBsoqkJJP0yXXLtpqsBCv8vm7RYqCn5+yfkiCQiXvkJBz\n
			FSKmLF9EPR9l1H+32Id82dDuseD70D66puPUHjciEgmU18DpW2NVvTAykMwTEsiR\n
			0h/ExBEhUe75qtwlVno8cMFbEfVtiGbKECvWIr122ED71T0Jt2Bcxqx1a7c1hPIV\n
			RwLxIfWfE0+2rB9nJVPBgsTVPywibDvjio82FousyMDmvkAbMq5iyuyvJ0+5bATz\n
			o12GEt5lSiQlCMzfmkWYBROMDCh27qGFVVo1XAUCVsMfsW9n4iQcoLAdUp/LI3B3\n
			ywIDAQAB\n
			-----END PUBLIC KEY-----\n
			""".trimIndent()
	}

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

}

Edit Android.xml manifest

Paste the meta-data and provider into your app's AndroidMainfest.xml that were output to the console in Output source code snippets.

<?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
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:theme="@style/AppTheme">

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

Test your configuration

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

Compile and run Quickstart to the same Emulator instance that Appfigurate Emulator was run from previously.

Tap the Appfigurate app icon.

Tap the Quickstart row. Appfigurate will read the configuration from the Quickstart app.

Appfigurate will now display the following screen:

Since we added a @BooleanProperty for debugLogging and @StringPropertyListEdit for serverURL, you can now change these configuration items at runtime. Tap Apply⌄ to apply the configuration to the Quickstart app.

Now jump to Supported property types.

Last updated