0
0
Android Kotlinmobile~10 mins

Firebase project setup 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 in your Android app's main activity.

Android Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  setContentView(R.layout.activity_main)
  Firebase[1].initializeApp(this)
}
Drag options to blanks, or click blank then click option'
AApp
BAuth
CDatabase
DFirestore
Attempts:
3 left
💡 Hint
Common Mistakes
Using FirebaseAuth or FirebaseDatabase instead of FirebaseApp.
Forgetting to call initialize in onCreate.
2fill in blank
medium

Complete the code to add Firebase Analytics to your app.

Android Kotlin
val analytics = FirebaseAnalytics[1](this)
Drag options to blanks, or click blank then click option'
A.setup
B.initialize
C.getInstance
D.create
Attempts:
3 left
💡 Hint
Common Mistakes
Using initialize or create instead of getInstance.
Not passing the context 'this' as parameter.
3fill in blank
hard

Fix the error in the Firebase Realtime Database reference code.

Android Kotlin
val database = FirebaseDatabase.getInstance()
val myRef = database.[1]("message")
Drag options to blanks, or click blank then click option'
AgetRef
BgetReference
Cref
Dreference
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reference' or 'ref' which are not methods.
Using 'getRef' which does not exist.
4fill in blank
hard

Fill both blanks to complete the Firebase Cloud Firestore initialization and get a collection reference.

Android Kotlin
val db = FirebaseFirestore[1]()
val usersRef = db.[2]("users")
Drag options to blanks, or click blank then click option'
AgetInstance
Bcollection
CgetCollection
Dinitialize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize' instead of 'getInstance'.
Using 'getCollection' which is not a Firestore method.
5fill in blank
hard

Fill all three blanks to complete the Firebase Authentication sign-in with email and password code.

Android Kotlin
val auth = FirebaseAuth[1]()
auth.[2]WithEmailAndPassword(email, password)
  .addOnCompleteListener(this) { task ->
    if (task.[3]()) {
      // Sign in success
    } else {
      // Sign in failed
    }
  }
Drag options to blanks, or click blank then click option'
AgetInstance
Binstance
CisSuccessful
DsignIn
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'signIn' instead of 'getInstance' for first blank.
Using 'instance' instead of 'signIn' for second blank.
Checking 'task.success' instead of 'task.isSuccessful()'.