AppGallery Connect Remote Configuration allows you to manage parameters online. With the service, you can change the behavior and appearance of your app online without requiring users to update the app. Remote Configuration provides cloud-based services, the console, and the client SDK. By integrating the client SDK, your app can periodically obtain parameter values delivered on the console to modify the app's behavior and appearance.
What You Will Create
In this codelab, you will build an app that can use AppGallery Connect Remote Configuration to configure the app UI text. Your app will be able to:
Change the text and its boldfaced status by defining parameters in Remote Configuration.
Localize the greeting based on the system language.
What You Will Learn
Integrate Remote Configuration of AppGallery Connect.
Change how your app acts and looks by changing parameters through Remote Configuration.
Development Environment and Skill Requirements
A computer with Android Studio installed for app development
Sign in to AppGallery Connect and click My projects. Click the app for which you want to enable Remote Configuration on the project card, and go to Growing > Remote Configuration. If it is the first time that you use Remote Configuration, click Enable now in the upper right corner.
If you are using Android Studio, you can integrate the Remote Configuration SDK by using the Maven repository into your Android Studio project before development.
Click My projects in AppGallery Connect and find the app for which you want to enable Remote Configuration on the project card.
Go to Project Settings > General information, and click agconnect-services.json to download the configuration file.
Copy the agconnect-services.json file to the app's root directory of your Android Studio project.
Open the build.gradle file in the app directory and configure the service addresses for Remote Configuration as follows.
// Configure the following address:
apply plugin: 'com.huawei.agconnect'
// Configure the following address.
Click Sync Now to synchronize the configuration.
In this codelab, you can create a UI layout in the Android Studio project, design the layout based on the following figure, and add a simple text, and a button for obtaining parameters from Remote Configuration.
As you need to implement functions including localizing the greeting, and changing the boldfaced status, the following parameters need to be designed:
GREETING_KEY: greeting text
SET_BOLD_KEY: indicates whether the text is in bold. The options are true (yes) and false (no).
When an app is launched, it loads default parameter values. In this codelab, you will use in-app default parameter values. Create an XML file in the res/xml directory and set the default value for each parameter.
Sign in to AppGallery Connect and click My projects. Click your app on the project card, and go to Growing > Remote Configuration.
Click the Condition management tab and then click Add condition.
In the dialog box that is displayed, set Condition for the current language Chinese, for example Diff_Lang_CN, set Language as the filter, select Chinese(zh) for Language, and click Save.
Add a condition for the language English in the same way, for example, Diff_Lang_EN. In this case, select English(US)(en) for Language. After the conditions are added, click Release.
Click the Parameter management tab and then click Add parameter.
Enter a parameter name in Default parameter name based on your design, for example, GREETING_KEY. Enter a default value for the parameter in Default value, for example, Greeting, CodeLaber.
Select Diff_Lang_CN from the Add conditional value drop-down list box. Set the value to be displayed in Chinese for the GREETING_KEY parameter. Then select Diff_Lang_EN from the Add conditional value drop-down list box, and set the value to be displayed in English for this parameter. After the configuration is complete, click Save.
Click Add parameter again to add the SET_BOLD_KEY parameter. Enter a default value for the parameter in Default value, for example, false. For Chinese, set the parameter to true, indicating that text is in bold. For English, set the parameter to false, indicating that the text is not in bold. After the configuration is complete, click Save.