目前,我的会话始终为空,假设捆绑不会为空。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_scene);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
RelativeLayout rLayout = (RelativeLayout) findViewById(R.id.splashbg);
rLayout.setBackgroundResource(R.drawable.default_bg);
Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
Session session = Session.getActiveSession();
if (session == null) {
if (session == null) {
session = new Session(this);
}
Session.setActiveSession(session);
}
session = Session.getActiveSession();
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
session.openForRead(new Session.OpenRequest(SplashScene.this)
.setCallback(statusCallback));
} else {
updateView();
}
}
@Override
public void onBackPressed() {
// disable back button by overriding it
}
@Override
public void onStart() {
super.onStart();
Session.getActiveSession().addCallback(statusCallback);
}
@Override
public void onStop() {
super.onStop();
Session.getActiveSession().removeCallback(statusCallback);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode,
resultCode, data);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Session session = Session.getActiveSession();
Session.saveSession(session, outState);
}
private class SessionStatusCallback implements Session.StatusCallback {
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
GlobalFunction.token = session.getAccessToken();
IsExistMember checkmember = new IsExistMember();
checkmember.execute();
}
}
}
private void updateView() {
Session session = Session.getActiveSession();
if (!session.isOpened() && !session.isClosed()
&& session.getState() != SessionState.OPENING) {
OpenRequest open = new OpenRequest(this)
.setCallback(statusCallback);
List<String> permission = new ArrayList<String>();
permission.add("email");
open.setPermissions(permission);
session.openForRead(open.setCallback(statusCallback));
} else {
Session.openActiveSession(this, true, statusCallback);
// Intent intent = new Intent(SplashScene.this, WelcomeScene.class);
// startActivity(intent);
// finish();
}
}
如何将会话保留在手机中,下次运行此应用程序时无需创建新会话。
我正在检查这个会话Activity
。如果存在,则继续进行其他活动以使用 facebook 登录并将捆绑包保存到手机中。
根据教程,它被教导用 an 做所有事情,Activity
但我想在不同的Activity
.
有类似的东西sharedpreference
,我认为它与 iOS 相同appdelegate
吗?