Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. package com.example.n0614144.studioa;
  2.  
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.support.annotation.NonNull;
  6. import android.support.annotation.Nullable;
  7. import android.support.v4.app.Fragment;
  8. import android.view.LayoutInflater;
  9. import android.view.View;
  10. import android.view.ViewGroup;
  11. import android.widget.Button;
  12.  
  13. import com.google.firebase.auth.FirebaseAuth;
  14. import com.google.firebase.database.DatabaseReference;
  15. import com.google.firebase.database.FirebaseDatabase;
  16.  
  17. public class ProfileFragment extends Fragment implements View.OnClickListener {
  18.  
  19. private FirebaseAuth auth;
  20. private DatabaseReference mDatabase;
  21. public Button b;
  22.  
  23. @Nullable
  24. @Override
  25. public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  26. View v = inflater.inflate(R.layout.fragment_profile, container, false);
  27. b = v.findViewById(R.id.signoutButton);
  28. b.setOnClickListener(this);
  29.  
  30. return v;
  31. }
  32.  
  33. public void onCreate() {
  34. auth = FirebaseAuth.getInstance();
  35. mDatabase = FirebaseDatabase.getInstance().getReference();
  36.  
  37. }
  38.  
  39. @Override
  40. public void onClick(View v) {
  41. switch (v.getId()) {
  42. case R.id.signoutButton:
  43. auth = FirebaseAuth.getInstance();
  44. auth.signOut();
  45. Intent intent = new Intent(getActivity(),LoginActivity.class);
  46. startActivity(intent);
  47. break;
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement