0
Firebase problem!(It's not connected with not having the internet in emulator Or with enabling auth in firebase menu)  When i created login and password everything worked fine after that i connected Realtime database and since that i get an error "ignoring header X-Firebase-Locale because its value was null."   When i delete database and leave only registration and login everything works fine.

// change means what i changed since i created realtime database













import android.content.Intent  
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.Toast                                 register activity
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.auth.FirebaseAuth                   
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase

class Register : AppCompatActivity() {
    private lateinit var edtEmail2: EditText
    private lateinit var edtPassword2: EditText
    private lateinit var edtName: EditText                  //change
    private lateinit var btnSignUp2: Button
    private lateinit var mAuth: FirebaseAuth
    private lateinit var mDbRef: DatabaseReference


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_register)

        supportActionBar?.hide()                                //change
        edtName = findViewById(R.id.name)                        //change2
        edtEmail2 = findViewById(R.id.Email2)
        edtPassword2 = findViewById(R.id.Password2)
        btnSignUp2 = findViewById(R.id.Register2)

        mAuth = FirebaseAuth.getInstance()

        btnSignUp2.setOnClickListener {
            val email = edtEmail2.text.toString()
            val name = edtName.text.toString()        //change
            val password = edtPassword2.text.toString()
            signUp(email, password, name)                 // change
        }

    }

    private fun signUp(name: String, email: String, password: String) {         //change

        mAuth.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(this) { task ->
                if (task.isSuccessful) {
                    //code for jumping to profile
                    addUserToDatabase(name,email,mAuth.currentUser?.uid!!)          //change

                    val intent = Intent(this@Register, Profile::class.java)
                    startActivity(intent)
                } else {
                    Toast.makeText(this@Register, "An error has occured", Toast.LENGTH_SHORT).show()                     //Ohhh

                }
            }

    }
 //Ohhh //Ohhh

Please add some context to explain the code sections (or check that you have not incorrectly formatted all of your question as code). private fun addUserToDatabase(name: String, email: String, uid: String){ //change mDbRef = FirebaseDatabase.getInstance().reference mDbRef.child("user").child(uid).setValue(User(name, email, uid)) //change

    }



    }
simon
  • 1
  • 1
    Don't share all the code... Share issue part and write what is the issue... Others can't spend much time – Gobu CSG Jul 06 '22 at 19:17
  • Check this might be same issue https://stackoverflow.com/questions/64727665/w-system-ignoring-header-x-firebase-locale-because-its-value-was-null – Gobu CSG Jul 06 '22 at 19:20

0 Answers0