title: Setter and Getter returns null to get name, email, profile pic, and id from Facebook Login
body: <p>So I plan to store the info from loging in facebook to a getter and setter so that i could post it could be posted in my Firebase database from BroadcastFragment.java.  What I dont understand is why it always return null.  Is where/how I put my setter in FacebookLogin.java wrong? Is there something wrong with my User.java? </p>
  
  <p>FacebookLogin.java</p>
  
  <pre><code>public class FacebookLogin extends AppCompatActivity{
  private static final String TAG = "FacebookLogin";
  
  private LoginButton loginButton;
  private CallbackManager callbackManager;
  private FirebaseAuth firebaseAuth;
  private FirebaseAuth.AuthStateListener firebaseAuthListener;
  public DatabaseReference mRootRef;
  public Firebase mRef;
  private ProgressBar progressBar;
  
  private final String uid = getUid();
  
  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      FacebookSdk.sdkInitialize(getApplicationContext());
      setContentView(R.layout.facebook_login);
      Firebase.setAndroidContext(this);
  
      mRootRef = FirebaseDatabase.getInstance().getReference();
      mRef = new Firebase("https://peoplehelper-c5a97.firebaseio.com/users");
  
      progressBar = (ProgressBar) findViewById(R.id.progressBar);
  
      callbackManager = CallbackManager.Factory.create();
      loginButton = (LoginButton) findViewById(R.id.loginButton);
      loginButton.setReadPermissions(Arrays.asList("email", "public_profile"));
      loginButton.registerCallback(callbackManager, new FacebookCallback&lt;LoginResult&gt;()
      {
          @Override
          public void onSuccess(LoginResult loginResult)
          {
              Log.d("", "facebook:onSuccess:" + loginResult);
              handleFacebookAccessToken(loginResult.getAccessToken());
          }
  
          @Override
          public void onCancel()
          {Toast.LENGTH_SHORT).show();
              Log.d(TAG, "facebook:onCancel");
          }
  
          @Override
          public void onError(FacebookException error)
          {
              //Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
              Log.d(TAG, "facebook:onError", error);
          }
      });
  
      firebaseAuth = FirebaseAuth.getInstance();
      firebaseAuthListener = new FirebaseAuth.AuthStateListener()
      {
          @Override
          public void onAuthStateChanged(@NotNull FirebaseAuth firebaseAuth)
          {
              FirebaseUser user = firebaseAuth.getCurrentUser();
              if (user != null)
              {
                  Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
              }
              else
              {
                  Log.d(TAG, "onAuthStateChanged:signed_out");
              }
          }
      };
  
  }
  
  private void handleFacebookAccessToken(AccessToken accessToken)
  {
      Log.d(TAG, "handleFacebookAccessToken:" + accessToken);
  
      progressBar.setVisibility(View.VISIBLE);
      loginButton.setVisibility(View.GONE);
      final FirebaseUser users = FirebaseAuth.getInstance().getCurrentUser();
  
      /**String uid = users.getUid();*/
  
      AuthCredential credential = FacebookAuthProvider.getCredential(accessToken.getToken());
      firebaseAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;()
      {
          public String facebookUserId;
          String uid = users.getUid();
  
          @Override
          public void onComplete(@NotNull Task&lt;AuthResult&gt; task)
          {
              if (!task.isSuccessful())
              {
                  Log.w(TAG, "signInWithCredential", task.getException());
                  Toast.makeText(FacebookLogin.this, "Authentication failed.",
                          Toast.LENGTH_SHORT).show();
                  //Toast.makeText(getApplicationContext(), "Authentication Failed", Toast.LENGTH_SHORT).show();
  
                  // Log.d(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());
              }
              else
              {
                  String uid=task.getResult().getUser().getUid();
                  String name=task.getResult().getUser().getDisplayName();
                  String email=task.getResult().getUser().getEmail();
                  String image=task.getResult().getUser().getPhotoUrl().toString();
  
  
                  Profile profile = Profile.getCurrentProfile();
                  facebookUserId = profile.getId();
                  String facebookId=facebookUserId;
  
  
                  User users = new User(uid,name,email,facebookId);
                  users.setUserId(uid);
                  users.setUserName(name);
                  users.setUserEmail(email);
                  // mEmailRef = mRootRef.child("users").child(userId).child("email”)
                  // Firebase mRefChild = mRef.child("Name").child(uid).child("email");
                  mRef.child(uid).setValue(users);
  
                  Intent intent = new Intent(getApplicationContext() ,Home.class);
                  intent.putExtra("user_id",uid);
                  intent.putExtra("profile_picture",image);
  
                  startActivity(intent);
                  finish();
                  goMainScreen();
              }
              progressBar.setVisibility(View.VISIBLE);
              loginButton.setVisibility(View.GONE);
          }
      });
  }
  
  private void goMainScreen()
  {
      Intent intent = new Intent (this, Home.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
      startActivity(intent);
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data)
  {
      super.onActivityResult(requestCode, resultCode, data);
      callbackManager.onActivityResult(requestCode, resultCode, data);
  }
  
  @Override
  protected void onStart()
  {
      super.onStart();
      firebaseAuth.addAuthStateListener(firebaseAuthListener);
  }
  
  @Override
  protected void onStop()
  {
      super.onStop();
      firebaseAuth.removeAuthStateListener(firebaseAuthListener);
  }
  
  public String getUid()
  {
      return uid;
  }
  }
  </code></pre>
  
  <p>BroadcastFragment.java</p>
  
  <pre><code>public class BroadcastFragment extends Fragment implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener{
      int day, month, year, hour, minute;
      int dayFinal, monthFinal, yearFinal, hourFinal, minuteFinal;
      Button deadline;
      EditText reqdesc;
      Button post;
      public String dead="", role="requester", r;
      DatabaseReference dr;
      String uid="", uname="", uemail="";
      User u = new User();
  
  View myView;
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      myView = inflater.inflate(R.layout.broadcast, container, false);
      dr = FirebaseDatabase.getInstance().getReference("BroadcastRequest");
  
  
      reqdesc = (EditText) myView.findViewById(R.id.reqdesc);
      deadline = (Button) myView.findViewById(R.id.deadline);
      deadline.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v) {
              Calendar c = Calendar.getInstance();
              year = c.get(Calendar.YEAR);
              month = c.get(Calendar.MONTH);
              day = c.get(Calendar.DAY_OF_MONTH);
              DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), BroadcastFragment.this,
                      year, month, day);
              datePickerDialog.show();
          }
      });
      post = (Button) myView.findViewById(R.id.post);
      post.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              dead = deadline.getText().toString();
              r = reqdesc.getText().toString();
              uid = u.UserId();
              uname = u.UserName();
              uemail = u.UserEmail();
              writeNewRequest(r, dead, uemail, uid, uname, role, "Siquijor");
              showNotification();
          }
      });
  
  
      return myView;
  }
  private void writeNewRequest(String r, String dead, String email, String id, String name, String role, String cl) {
      DatabaseReference post = dr.push();
      String date = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
  
      post.child("RequestDeadline").setValue(dead);
      post.child("RequestDescription").setValue(r);
      post.child("email").setValue(email);
      post.child("id").setValue(id);
      post.child("name").setValue(name);
      post.child("role").setValue(role);
      post.child("CurrentDateTime").setValue(date);
      post.child("CurrentLocation").setValue(cl);
  }
  
  @Override
  public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
      yearFinal = year;
      monthFinal = month;
      dayFinal = dayOfMonth;
  
      Calendar c = Calendar.getInstance();
      hour = c.get(Calendar.HOUR_OF_DAY);
      minute = c.get(Calendar.MINUTE);
  
  
      TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), BroadcastFragment.this,
              hour, minute, DateFormat.is24HourFormat(getActivity()));
      timePickerDialog.show();
  }
  
  @Override
  public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
      hourFinal = hourOfDay;
      minuteFinal = minute;
      String monthname = monthName(monthFinal);
      String time = midnight(hourFinal,minuteFinal);
  
      String dl = monthname+" "+dayFinal+" "+yearFinal+" "+time;
  
      deadline.setText(dl);
  
  }
  private String midnight(int h, int m){
      String mid="", hour="";
      if(h&lt;=11){
          mid = "AM";
          if(h==00)
              h=12;
      }
      else if(h&gt;=12){
          mid = "PM";
          if(h&gt;=13)
              h-=12;
      }
      hour = number(h);
      String minute = number(m);
      String t = hour+":"+minute+mid;
      return t;
  }
  private String number(int n){
      String a = Integer.toString(n);
      if(n&lt;=9){
          a = "0"+a;
          return a;
      }
      else
          return a;
  }
  private String monthName(int month){
      month+=1;
      String mn="";
      switch (month){
          case 1: mn="January";
              break;
          case 2: mn="February";
              break;
          case 3: mn="March";
              break;
          case 4: mn="April";
              break;
          case 5: mn="May";
              break;
          case 6: mn="June";
              break;
          case 7: mn="July";
              break;
          case 8: mn="August";
              break;
          case 9: mn="September";
              break;
          case 10: mn="October";
              break;
          case 11: mn="November";
              break;
          case 12: mn="December";
              break;
      }
      return mn;
  }
  
  public void showNotification(){
      NotificationCompat.Builder builder = new NotificationCompat.Builder(getActivity());
      builder.setSmallIcon(R.mipmap.ic_launcher);
      builder.setContentTitle("PEOPLE HELPER");
      builder.setContentText("Your request has been broadcasted");
  
      Intent intent = new Intent(getActivity(), BroadcastFragment.class); //creates an explicit intent
      TaskStackBuilder stackBuilder = TaskStackBuilder.create(getActivity());
      stackBuilder.addParentStack(getActivity()); //adds the intent
      stackBuilder.addNextIntent(intent);  //put the intent to the top of the stack
      PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); //(id, flag) //creates a pending intent
      builder.setContentIntent(pendingIntent); //adds the PendingIntent to the builder
      NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
      notificationManager.notify(0, builder.build());
  }
  
  }
  </code></pre>
  
  <p>User.java</p>
  
  <pre><code>public class User {
      public String uid;
      public String name;
      public String email;
      public String facebookId;
  
      public User(){
  
      }
  
      public User(String uid, String name, String email, String facebookId)
      {
          this.uid = uid;
          this.name = name;
          this.email = email;
          this.facebookId = facebookId;
      }
      public void setUserId(String uid)
      {
          this.uid = uid;
      }
      public void setUserName(String name){
          this.name = name;
      }
      public void setUserEmail(String email){
          this.email = email;
      }
      public String UserId(){
          return uid;
      }
      public String UserName(){
          return name;
      }
      public String UserEmail(){
          return email;
      }
  }
  </code></pre>