0
我正在制作一个Android应用程序,它提供使用谷歌登录。我已成功登录。现在,我想在下次打开应用程序时将用户直接带到仪表板。那么如何检查他是否已经使用Google帐户登录过。检查用户是否在使用谷歌帐户looged
我正在制作一个Android应用程序,它提供使用谷歌登录。我已成功登录。现在,我想在下次打开应用程序时将用户直接带到仪表板。那么如何检查他是否已经使用Google帐户登录过。检查用户是否在使用谷歌帐户looged
使用silentSignIn
如下所示从GoogleSignInApi
。这很棒。并且还使用sharedPreference将状态保持为loggedIn或loggedOut。
@Override
public void onStart() {
super.onStart();
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
//If the user is signIn and cached or else try again logging
Log.d(TAG, "Got cached sign-in|| " + opr.isDone());
if (opr.isDone() && BankerPrefs.isLogin(this)) {
GoogleSignInResult result = opr.get();
handleSignInResult(result);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
使用shredpreference..Store登录ID在pref –