简体   繁体   中英

how to check whether user is login or not in Android Google+ sign in

I have LoginActivity and MainActivity.

in LoginActivity, there are Facebook LoginButton and Google+ LoginButton

In the case of Facebook login , I can check whether user is login or not in MainActivity

through this.

mToken = AccessToken.getCurrentAccessToken();

   if (mToken == null ){
            Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
            startActivity(intent);
        }

but i don't know how to check Google account.

is there any method like mToken = AccessToken.getCurrentAccessToken(); ?

if not, how do i know whether users logged in or not?

 @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    callbackManager.onActivityResult(requestCode, resultCode, data);

    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        int statusCode = result.getStatus().getStatusCode();
        if (result.isSuccess()) {
            GoogleSignInAccount acct = result.getSignInAccount();

// Get account information

            assert acct != null;
            String mEmail = acct.getEmail();
            String mUserId = acct.getId();

// handleSignInResult(result);

        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM