In my project, There is a splashActivity
then LoginActivity
and on click 社交账号登录
it takes to SocialCountLoginActivity
. If someone click on QQ login and if login get success then MainActivity
starts. At that time I am finishing the LoginActivity
and SocialCountLoginActivity
.On restart application it's taking to LoginAcivity
instead of MainActivity
. What should I do to start MainAcivity
directly after successful login?
The following is my screenshot:
The folowing is my socialcountloginactivity part code:
private class QQUIListener implements IUiListener{
@Override
public void onComplete(Object response) {
//Login sucess
//finish();
JSONObject object = (JSONObject) response;
initOpenidAndToken(object);
getUserInfo();
}
@Override
public void onError(UiError uiError) {
//Login fail
}
@Override
public void onCancel() {
//Cancle Login
}
}
The following is mainactivity code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// finish activity
ActivityManagerUtil.finishSomeOneActivity(SocialAccountLoginActivity.class);
ActivityManagerUtil.finishSomeOneActivity(LoginActivity.class);
}
Use shared preferences to store login details and check when your application starts. If there is some detail stored then start your main activity else navigate to login activity. If your are very new to android development then go through some session management tutorials you will get better understanding: Like:- http://www.androidhive.info/2012/08/android-session-management-using-shared-preferences/ - https://www.tutorialspoint.com/android/android_session_management.htm