In my application I am using authentication with Google account. When the user logs in for the first time list of google accounts used on the device is displayed and user can log in by picking one of available accounts. But when the user logs out and then try to log in again the list is no longer displayed and he is automatically logged with previously picked account. How can I prevent my app from remembering that account and force it to display account list on every log in try?
Asked
Active
Viewed 369 times
4 Answers
0
This might help you
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
}
});
}
Ankur Samarya
- 219
- 1
- 3
- 15
0
You have to call log out onDestroy()
Auth.GoogleSignInApi.signOut(mGoogleApiClient)
For more info look at here. https://stackoverflow.com/a/38977378/5558150
Bhuvanesh BS
- 13,474
- 12
- 40
- 66
0
can you try this one this one I think this one help you, this is working in my application
private void googleSignOut() {
if (mGoogleApiClient.isConnected()) {
Auth.GoogleSignInApi.signOut(mGoogleApiClient).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
LogUtils.LOGD(TAG, String.valueOf(status.getStatusMessage()));
}
});
}
}
Kishan Donga
- 2,851
- 2
- 23
- 35
-
Not working in mine. Still not prompted to choose account on login. – Andy Sep 22 '17 at 12:17
0
For logout you have to revoke access than logout than disconnect for clear data of account
public void logout() {
Log.i("mymsg --->", "GP logout");
if (objLoginUtl.isGooglePlusLogin()) {
Plus.AccountApi.revokeAccessAndDisconnect(MyGooglePlus.mGoogleApiClient);
Plus.AccountApi.clearDefaultAccount(MyGooglePlus.mGoogleApiClient);
Auth.GoogleSignInApi.revokeAccess(MyGooglePlus.mGoogleApiClient);
Auth.GoogleSignInApi.signOut(MyGooglePlus.mGoogleApiClient);
MyGooglePlus.mGoogleApiClient.disconnect();
MyGooglePlus.mGoogleApiClient.connect();
Log.i("mymsg --->", "GP logout clear defulat a/c");
} else{
Log.i("mymsg --->", "in Else");
}
}
Upendra Shah
- 2,218
- 17
- 27