1. Are you ready for the Galaxy S20? Here is everything we know so far!

Login app just terminate whenever it starts.

Discussion in 'Android Development' started by farter, Jul 29, 2021.

  1. farter

    farter Lurker
    Thread Starter

    I made a layout like this (Two EditTexts ,Two buttons.), and codes are below .

    class RegisterActivity: AppCompatActivity() {

    private lateinit var mFirebaseAuth: FirebaseAuth
    private lateinit var mEdID: EditText
    private lateinit var mEdPW: EditText

    override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
    super.onCreate(savedInstanceState, persistentState)

    mFirebaseAuth = Firebase.auth
    mEdID = findViewById<EditText>(R.id.editTextID)
    mEdPW = findViewById<EditText>(R.id.editTextPW)

    //registration button
    btn_register.setOnClickListener {
    val strEmail = mEdID.getText().toString()
    val strPW = mEdPW.getText().toString()

    mFirebaseAuth.createUserWithEmailAndPassword(strEmail, strPW)
    .addOnCompleteListener(this) { task ->
    if (task.isSuccessful()) {
    Log.w(TAG, "successful registration")
    val firebaseuser = mFirebaseAuth.currentUser
    } else {
    Log.w(TAG, "registration failed", task.exception)
    Toast.makeText(baseContext, "registration failed",

    //login button
    val strEmail = mEdID.getText().toString()
    val strPW = mEdPW.getText().toString()

    .addOnCompleteListener(this) { task->
    Log.d(TAG, "successful login")
    val user = mFirebaseAuth.currentUser
    Log.w(TAG, "login failed", task.exception)
    Toast.makeText(baseContext, "login failed.",

    I wrote codes in onCreate , and the app just terminate whenever activity start.
    I don't know why this happens.

    1. Download the Forums for Android™ app!


  2. Sumbul

    Sumbul Lurker

    If you are in Makkah and Planning to visit Makkah. then you must know these 10 things to buy in mecca. This article will guide you about the exploring Makkah and what you should buy from there

Share This Page