Firstly, I tried alone to make a simple registration code to my application and it worked:
public class MainActivity extends AppCompatActivity {
private static final String FIREBASE_URL="https://***.firebaseio.com/";
private Firebase firebaseRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Firebase.setAndroidContext(this);
firebaseRef = new Firebase(FIREBASE_URL);
findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText fullname=(EditText)findViewById(R.id.full_name);
EditText email=(EditText)findViewById(R.id.mail);
EditText restname=(EditText)findViewById(R.id.rest_name);
EditText phonenum=(EditText)findViewById(R.id.phone_num);
EditText userpass=(EditText)findViewById(R.id.user_pass);
EditText personalcode=(EditText)findViewById(R.id.personal_code);
String full_name=fullname.getText().toString();
String mail=email.getText().toString();
String rest_name=restname.getText().toString();
String phone_num=phonenum.getText().toString();
String user_pass=userpass.getText().toString();
String personal_code=personalcode.getText().toString();
if(full_name!=""&&mail!=""&&rest_name!=""&&phone_num!=""&&user_pass!=""&&personal_code!="")
{
UserClass user= new UserClass(full_name,mail,rest_name,phone_num,user_pass,personal_code);
firebaseRef.push().setValue(user);
fullname.setText("");
email.setText("");
clubname.setText("");
phonenum.setText("");
userpass.setText("");
personalcode.setText("");
Toast.makeText(MainActivity.this,"Account Inserted",Toast.LENGTH_LONG).show();
}
}
});
}
So as I said, it worked well and the information was inserted to the Firebase database well.
But I found a problem with the login part. I could'nt find any guide that shows how to make a login from the information I've inserted to the Firebase database with the registration code I wrote above.
What are you recommending me to do? Did the way I write the registration code is recommended? If yes - How should I code the login page? If no - what is the best way to make registeration or login for an android application with Firebase?
Thanks alot!