Exemplo n.º 1
0
 @Override
 public void onResume() {
   super.onResume();
   if (Session.initializeSession(getActivity(), callback)) {
     // Session opening
   } else if (Session.getCurrentSession().isOpened()) {
     onSessionOpened();
   }
 }
Exemplo n.º 2
0
    public void onSessionOpened() {
      UserProfile userProfile = UserProfile.loadFromCache();
      if (userProfile != null && userProfile.getId() != Long.MIN_VALUE) {
        Toast.makeText(
                getActivity(),
                "user id : "
                    + String.valueOf(userProfile.getId())
                    + "\naccess_token : "
                    + Session.getCurrentSession().getAccessToken(),
                Toast.LENGTH_SHORT)
            .show();
      } else {

        UserManagement.requestMe(
            new MeResponseCallback() {

              @Override
              protected void onSuccess(final UserProfile userProfile) {
                Logger.getInstance().d("UserProfile : " + userProfile);
                userProfile.saveUserToCache();
                Toast.makeText(
                        getActivity(),
                        "user id : "
                            + String.valueOf(userProfile.getId())
                            + "\naccess_token : "
                            + Session.getCurrentSession().getAccessToken(),
                        Toast.LENGTH_SHORT)
                    .show();
              }

              @Override
              protected void onNotSignedUp() {}

              @Override
              protected void onSessionClosedFailure(final APIErrorResult errorResult) {}

              @Override
              protected void onFailure(final APIErrorResult errorResult) {
                String message = "failed to get user info. msg=" + errorResult;
                Logger.getInstance().d(message);
              }
            });
      }
    }