Complete the code to initialize Firebase in an Android app.
FirebaseApp.[1](this)The method initializeApp sets up Firebase in your Android app.
Complete the code to get a reference to the Firebase Realtime Database.
val database = FirebaseDatabase.[1]()getInstance() returns the Firebase Realtime Database instance.
Fix the error in the code to write data to Firebase Realtime Database.
database.[1]("users").setValue(user)
The correct method to get a child reference in the database is child.
Fill both blanks to read data from Firebase Realtime Database asynchronously.
database.[1]("messages").addListenerForSingleValueEvent(object : ValueEventListener { override fun onDataChange(snapshot: DataSnapshot) { val data = snapshot.[2]() } override fun onCancelled(error: DatabaseError) {} })
Use getReference to point to the path, and getValue() to get the data snapshot value.
Fill all three blanks to authenticate a user with Firebase using email and password.
FirebaseAuth.[1]().[2](email, password).addOnCompleteListener { task -> if (task.[3]()) { // User signed in } }
Use getInstance() to get FirebaseAuth, then signInWithEmailAndPassword to sign in, and check isSuccessful() on the task.