我在我的应用程序中使用 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);
}