Kotlin Firebase UserAuthentication need assistance

200
February 14, 2018, at 8:08 PM

Hey Guys Im trying to push the user data in kotlin to firebase but when i click the create account button nothing happends here is the code for Create account class

class CreateAccount : AppCompatActivity() {
var mAuth:FirebaseAuth?=null
var mdata:DatabaseReference?=null

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_create_account)
    mAuth= FirebaseAuth.getInstance()
    Createacc.setOnClickListener{
        var email=acemail.text.toString().trim()
        var pass=acpass.text.toString().trim()
        var name=acname.text.toString().trim()
        if(!TextUtils.isEmpty(email)||!TextUtils.isEmpty(name)||!TextUtils.isEmpty(pass)){
            createAccount(email,pass,name)
        }
        else{
            Toast.makeText(this,"Please fill all the details",Toast.LENGTH_LONG).show()
        }
    }
}
fun createAccount(email: String,password:String,dispname:String){
    mAuth!!.createUserWithEmailAndPassword(email,password).addOnCompleteListener(this,{
          task: Task<AuthResult> ->
        if(task.isSuccessful){
            var curruser=mAuth!!.currentUser
            var userid=curruser!!.uid
            Toast.makeText(this,"Building user wait",Toast.LENGTH_LONG).show()
            var uobject=HashMap<String,String>()
            uobject.put("Display_name",dispname)
            uobject.put("Status","Hi I'm New")
            uobject.put("image","default")
            uobject.put("thumb image","default")
            mdata=FirebaseDatabase.getInstance().reference.child("Users").child(userid)
            mdata!!.setValue(uobject).addOnCompleteListener{
                task:Task<Void>  ->
                if(task.isSuccessful){
                    Toast.makeText(this,"User Created",Toast.LENGTH_LONG).show()
                }
                else{
                    Toast.makeText(this,"OOPS!! User not Created",Toast.LENGTH_LONG).show()
                }
            }
        }
    })
}

} Main problem is in create account function ,it is being called correctly but right after the createUserWithEmailAndPassword function the task is not successfull hence the if loop does not run. There nothing is printed in the toast Neither "User created " nor "OOPS not created" i dont know whats going on. I have installed the firebase dependency and my app is connected to a firebase database.

Rent Charter Buses Company
READ ALSO
android downloadManager pause or stop when activity not in foreground

android downloadManager pause or stop when activity not in foreground

I am using DownloadManager for downloading learge file download from internet

224
get updated and lastknownlocation in a fragment

get updated and lastknownlocation in a fragment

Being very new to java, I am very confused about getting lastknownlocation and updated location

219
Make &ldquo;settings-like&rdquo; buttons in layouts

Make “settings-like” buttons in layouts

I am new to Android dev and kindly asking for help

222
Bengali not show properly in itext 5

Bengali not show properly in itext 5

I am trying to create a pdf to the Bengali languageBut not show in a proper format

236