アプリで Facebook ネイティブ ログイン認証を使用しています。ユーザーがログインボタンを押すと、ログイン後に次へ移動したいActivity
。ただし、ログイン後、ボタンはログアウトしてしばらくそこにとどまり、約20秒後に次のアクティビティに移動するように変更されました。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_main, container, false);
LoginButton authButton = (LoginButton) view
.findViewById(R.id.authButton);
authButton.setFragment(this);
authButton.setReadPermissions(Arrays.asList("email")); // permissions
internalStorageManipulator = new InternalStorageManipulator(
getActivity());
return view;
}
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,
Exception exception) {
if(!IsStateOpened)
onSessionStateChange(session, state, exception);
}
};
private void onSessionStateChange(Session session, SessionState state,
Exception exception) {
if (state.isOpened()) {
Request.executeMeRequestAsync(session,
new Request.GraphUserCallback() {
// callback after Graph API response with user
// object
@Override
public void onCompleted(GraphUser user,
Response response) {
if (user != null && !IsStateOpened) {
try {
internalStorageManipulator
.setLoginState(true);
Dashboard dashboard = new Dashboard(getActivity());
internalStorageManipulator.setUserID(user.getId());
internalStorageManipulator.setLoginState(true);
internalStorageManipulator.setGCMID("");
// getAsyncProfilePicture();
dashboard.LoginUser(user.getId(), user.asMap().get("email").toString(),user.getUsername(), "",
(IHttpRequestCallBack) c);
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
} else if (state.isClosed()) {
Log.i(LOGIN_TAG, "Logged out...");
}
}
@Override
public void onResume() {
super.onResume();
Session session = Session.getActiveSession();
if (!internalStorageManipulator.getLoginState())
if (session != null && (session.isOpened() || session.isClosed())) {
onSessionStateChange(session, session.getState(), null);
}
uiHelper.onResume();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
}