0
0
Android Kotlinmobile~10 mins

Firebase Analytics 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 initialize Firebase Analytics in an Android Kotlin app.

Android Kotlin
val firebaseAnalytics = FirebaseAnalytics.[1](this)
Drag options to blanks, or click blank then click option'
AgetInstance
Binitialize
Ccreate
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize' instead of 'getInstance' causes a compile error.
Trying to call 'create' or 'start' methods which do not exist.
2fill in blank
medium

Complete the code to log a custom event named "share_image" with Firebase Analytics.

Android Kotlin
val bundle = Bundle().apply {
  putString(FirebaseAnalytics.Param.METHOD, "[1]")
}
firebaseAnalytics.logEvent("share_image", bundle)
Drag options to blanks, or click blank then click option'
Abluetooth
Bsms
Csocial
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid method name that is not a string.
Forgetting to put the parameter inside the bundle.
3fill in blank
hard

Fix the error in the code to set the user ID for Firebase Analytics.

Android Kotlin
firebaseAnalytics.[1]("user_123")
Drag options to blanks, or click blank then click option'
AsetUserId
BsetUserID
CsetUser
DuserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'setUserID' with uppercase 'ID' causes a method not found error.
Using 'setUser' or 'userId' which are not valid methods.
4fill in blank
hard

Fill both blanks to create a bundle with a parameter for item ID and log an event named "select_content".

Android Kotlin
val bundle = Bundle().apply {
  putString(FirebaseAnalytics.Param.[1], "12345")
}
firebaseAnalytics.logEvent("[2]", bundle)
Drag options to blanks, or click blank then click option'
AITEM_ID
BCONTENT_TYPE
Cselect_content
Dview_item
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'CONTENT_TYPE' instead of 'ITEM_ID' for the parameter key.
Logging the wrong event name like 'view_item' instead of 'select_content'.
5fill in blank
hard

Fill all three blanks to create a bundle with item name and content type, then log a "view_item" event.

Android Kotlin
val bundle = Bundle().apply {
  putString(FirebaseAnalytics.Param.[1], "Sunglasses")
  putString(FirebaseAnalytics.Param.[2], "[3]")
}
firebaseAnalytics.logEvent("view_item", bundle)
Drag options to blanks, or click blank then click option'
AITEM_NAME
BCONTENT_TYPE
Caccessories
DITEM_ID
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up parameter keys like using 'ITEM_ID' instead of 'ITEM_NAME'.
Using an incorrect content type value.