0
0
Android Kotlinmobile~10 mins

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

Android Kotlin
private lateinit var auth: FirebaseAuth

override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)
  auth = FirebaseAuth.[1]()
}
Drag options to blanks, or click blank then click option'
Astart
BgetInstance
Ccreate
Dinitialize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'initialize' instead of 'getInstance' causes errors.
Trying to create a new FirebaseAuth object directly.
2fill in blank
medium

Complete the code to sign in a user with email and password using Firebase Authentication.

Android Kotlin
auth.signInWithEmailAndPassword(email, password)
  .addOnCompleteListener { task ->
    if (task.[1]()) {
      // Sign in success
    } else {
      // Sign in failed
    }
  }
Drag options to blanks, or click blank then click option'
AisDone
BisComplete
CisSuccessful
DisSuccess
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'isComplete' which only means the task finished, not success.
Using 'isDone' or 'isSuccess' which do not exist.
3fill in blank
hard

Fix the error in the code to send a password reset email using Firebase Authentication.

Android Kotlin
auth.[1](userEmail)
  .addOnCompleteListener { task ->
    if (task.isSuccessful) {
      // Email sent
    }
  }
Drag options to blanks, or click blank then click option'
AsendPasswordResetEmail
BresetPasswordEmail
CpasswordResetSend
DsendResetEmail
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names causes compile errors.
Trying to call a method that does not exist.
4fill in blank
hard

Fill both blanks to create a new user with email and password and handle success or failure.

Android Kotlin
auth.[1](email, password)
  .addOnCompleteListener { task ->
    if (task.[2]()) {
      // User created
    } else {
      // Creation failed
    }
  }
Drag options to blanks, or click blank then click option'
AcreateUserWithEmailAndPassword
BsignInWithEmailAndPassword
CisSuccessful
DisComplete
Attempts:
3 left
💡 Hint
Common Mistakes
Using signIn method instead of createUser method.
Checking 'isComplete' instead of 'isSuccessful'.
5fill in blank
hard

Fill all three blanks to get the current user, check if signed in, and get their email.

Android Kotlin
val user = auth.[1]
if (user != null) {
  val email = user.[2]
  println("User email: [3]")
}
Drag options to blanks, or click blank then click option'
AcurrentUser
Bemail
C$email
DgetCurrentUser
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method instead of property for current user.
Trying to call a method to get email instead of property.