1
페이스 북의 로그인을 사용하여 내 안드로이드 애플 리케이션에 로그인하고 있습니다. 여기에 액세스 토큰이 null인지 아닌지 확인 중이므로 로그인 후 다른 활동으로 이동할 수 있습니다. 이것은 잘 작동합니다. 페이스 북이 이미 로그인되어있을 때 다른 활동을 옮기는 더 좋은 방법이 있습니까?가장 좋은 방법은 이미 로그인되어있는 경우 안드로이드에서 페이 스북 로그인 페이지를 건너 뛰십시오
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_boringmain);
callbackManager = CallbackManager.Factory.create();
List<String> permissions = new ArrayList<>();
permissions.add("email");
loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(permissions);
profileTracker = new ProfileTracker() {
@Override
protected void onCurrentProfileChanged(Profile profile, Profile profile1) {
Profile.setCurrentProfile(profile1);
}
};
profileTracker.startTracking();
accessTokenTracker = new AccessTokenTracker() {
@Override
protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken,AccessToken currentAccessToken) {
AccessToken.setCurrentAccessToken(currentAccessToken);
}
};
if (AccessToken.getCurrentAccessToken()!=null) {
Intent intent = new Intent(boringmain.this, UserProfile.class);
startActivity(intent);
}
else
{
Log.e("S","User not logged in ");
}
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
getUserDetails(loginResult);
};
@Override
public void onCancel() {
// App code
}
위의 시나리오에는 더 좋은 방법이 있습니까? 프로필 추적기 및 액세스 토큰 추적기의 사용법이 맞습니까? 사용자가
if (AccessToken.getCurrentAccessToken()!=null)
좋은 방법입니다 호출하여 로그인 한 경우