I use Firebase and work in registration / login mode, but I also want each user to update the username. I can't seem to run:
firebaseRef.getAuth().getUid()
I get an error in the application emulator "unfortunately the application has stopped."
This looks like the main error I get in the Android studio on the monitor: something related to getUid ().
java.lang.NullPointerException: attempt to call the virtual method 'java.lang.String com.firebase.client.AuthData.getUid ()' to reference a null object
Here is my activity code:
package me.netsync.netconnect; import android.app.ActionBar; import android.content.Intent; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import com.firebase.client.AuthData; import com.firebase.client.Firebase; public class SettingActivity extends AppCompatActivity { private Firebase mRef; private Button BtnSettings; private EditText TxtUsername; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting); mRef = new Firebase(Constants.FIREBASE_URL); BtnSettings = (Button)findViewById(R.id.BtnSettings); BtnSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
Any pointers appreciated.
android firebase firebase-authentication
user3200080
source share