Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.nardeen.myapplication;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- public class MainActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Button signIn = (Button) findViewById(R.id.signInButton);
- signIn.onClickListener(new View.onClickListener());{
- @override
- public void onClick(View v){
- onSignInClickButton(v);
- }
- }
- }
- public void onSignInClickButton(View v){
- EditText textEmail = (EditText) findViewById(R.id.userEmail);
- EditText textPass = (EditText) findViewById(R.id.userPass);
- String email = (String) textName.getText().toString();
- String pass = (String) textPass.getText().toString();
- private FirebaseAuth mAuth;
- mAuth = FirebaseAuth.getInstance();
- mAuth.signInWithEmailAndPassword(email, pass)
- .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
- @Override
- public void onComplete(@NonNull Task<AuthResult> task) {
- if (task.isSuccessful()) {
- // Sign in success, update UI with the signed-in user's information
- Log.d(TAG, "signInWithEmail:success");
- FirebaseUser user = mAuth.getCurrentUser();
- updateUI(user);
- } else {
- // If sign in fails, display a message to the user.
- Log.w(TAG, "signInWithEmail:failure", task.getException());
- Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
- Toast.LENGTH_SHORT).show();
- updateUI(null);
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement