Advertisement
Guest User

Untitled

a guest
May 3rd, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. package com.example.nardeen.myapplication;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5.  
  6. public class MainActivity extends AppCompatActivity {
  7.  
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.activity_main);
  12.  
  13. Button signIn = (Button) findViewById(R.id.signInButton);
  14. signIn.onClickListener(new View.onClickListener());{
  15. @override
  16. public void onClick(View v){
  17. onSignInClickButton(v);
  18. }
  19. }
  20. }
  21.  
  22. public void onSignInClickButton(View v){
  23.  
  24. EditText textEmail = (EditText) findViewById(R.id.userEmail);
  25. EditText textPass = (EditText) findViewById(R.id.userPass);
  26.  
  27. String email = (String) textName.getText().toString();
  28. String pass = (String) textPass.getText().toString();
  29.  
  30. private FirebaseAuth mAuth;
  31. mAuth = FirebaseAuth.getInstance();
  32.  
  33. mAuth.signInWithEmailAndPassword(email, pass)
  34. .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
  35. @Override
  36. public void onComplete(@NonNull Task<AuthResult> task) {
  37. if (task.isSuccessful()) {
  38. // Sign in success, update UI with the signed-in user's information
  39. Log.d(TAG, "signInWithEmail:success");
  40. FirebaseUser user = mAuth.getCurrentUser();
  41. updateUI(user);
  42. } else {
  43. // If sign in fails, display a message to the user.
  44. Log.w(TAG, "signInWithEmail:failure", task.getException());
  45. Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
  46. Toast.LENGTH_SHORT).show();
  47. updateUI(null);
  48. }
  49.  
  50. }
  51. });
  52.  
  53.  
  54.  
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement