Issue
Though I controlled it with an if statement I'm getting ''Given string empty or null'' error and my app is closing.
fun kayitOl ( view : View) {
val email =findViewById<EditText>(R.id.emailText).text
val password = findViewById<EditText>(R.id.passwordText).text
if (email != null && password != null ) {
auth.createUserWithEmailAndPassword(email.toString(), password.toString())
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
val intent = Intent(this, haber_akisi::class.java)
startActivity(intent)
finish()
}
}.addOnFailureListener { exception ->
Toast.makeText(this, exception.localizedMessage, Toast.LENGTH_LONG).show()
}
}else {
Toast.makeText(this,"Lütfen E-mail ve Password alanlarını doldurunuz",Toast.LENGTH_LONG).show()
}
}
Solution
You check just for null
, but not for empty string ""
You can change your checking with email.isEmpty()
or better email.isBlank()
for checking strings like " "
Answered By - Cookie
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.