0
0
Android Kotlinmobile~10 mins

Remote Config in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get an instance of Firebase Remote Config.

Android Kotlin
val remoteConfig = FirebaseRemoteConfig.[1]()
Drag options to blanks, or click blank then click option'
Astart
Binitialize
Ccreate
DgetInstance
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize()' instead of 'getInstance()' causes a compile error.
Trying to create a new Remote Config object directly.
2fill in blank
medium

Complete the code to set default values from an XML resource file named 'remote_config_defaults'.

Android Kotlin
remoteConfig.[1](R.xml.remote_config_defaults)
Drag options to blanks, or click blank then click option'
AsetDefaults
BsetDefaultsAsync
CapplyDefaults
DloadDefaults
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'setDefaultsAsync' which does not exist.
Using 'loadDefaults' which is not a Remote Config method.
3fill in blank
hard

Fix the error in the code to fetch Remote Config values with a 1-hour cache expiration.

Android Kotlin
remoteConfig.fetch([1]).addOnCompleteListener { task ->
    if (task.isSuccessful) {
        remoteConfig.activate()
    }
}
Drag options to blanks, or click blank then click option'
A60
B3600
C3600000
D600
Attempts:
3 left
💡 Hint
Common Mistakes
Using milliseconds instead of seconds causes the cache to expire too late.
Using too small a number causes frequent fetches.
4fill in blank
hard

Fill both blanks to get a Remote Config string value for the key 'welcome_message'.

Android Kotlin
val welcomeMessage = remoteConfig.[1]("[2]")
Drag options to blanks, or click blank then click option'
AgetString
BgetValue
Cwelcome_message
DwelcomeMessage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getValue' returns a Remote Config value object, not a string.
Using a variable name instead of the key string.
5fill in blank
hard

Fill all three blanks to fetch, activate, and then print the Remote Config value for 'feature_enabled'.

Android Kotlin
remoteConfig.[1]().addOnCompleteListener { task ->
    if (task.isSuccessful) {
        remoteConfig.[2]()
        println(remoteConfig.[3]("feature_enabled"))
    }
}
Drag options to blanks, or click blank then click option'
Afetch
Bactivate
CgetString
DfetchAndActivate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fetchAndActivate' instead of separate fetch and activate calls.
Using 'getValue' instead of 'getString' to get the parameter value.