Issue
I have the problem when I want to register a new E-Mail to my firebase store.
I have that button in my activity_register.xml
:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RegisterActivity">
<EditText
android:id="@+id/editTextEmailAddress"
android:layout_width="237dp"
android:layout_height="49dp"
android:layout_marginTop="104dp"
android:layout_marginBottom="12dp"
android:background="@drawable/edittextbackground"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress"
android:padding="10dp"
android:textColor="@color/black"
app:layout_constraintBottom_toTopOf="@+id/editTextPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.502"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
....
After that I want to use it to register to the firebase store:
fun register(view: View){
val email: String=R.id.editTextEmailAddress.toString()
val password=R.id.editTextPassword.javaClass.toString()
auth.createUserWithEmailAndPassword(email,password).addOnCompleteListener { task ->
if(task.isSuccessful){
val intent= Intent(this,MainActivity::class.java)
startActivity(intent)
finish()
}
}.addOnFailureListener { exception ->
Toast.makeText(applicationContext,exception.localizedMessage,Toast.LENGTH_LONG).show()
}
}
If I take a look at the debugger there I can see the following:
It looks like it is an integer. How can I fix that Problem? I tried to solve it with bindings, but there the inflate is not possible.
Same Problem with the password one row below.
Solution
Problem is that you are taking the reference to the view instead, you should do like this
val emailField = findViewById(R.id.editTextEmailAddress)
val passwordField = findViewById(R.id.editTextPassword)
Now access the text
val email = emailField.text.toString()
val password = passwordField.text.toString()
Answered By - RaBaKa 78
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.