Resetting the Android SDK state
Resetting the Android SDK state implies the removal of cached data from memory. Access tokens will be removed and the user will be logged out. It won't, however delete the refresh token nor will it remove any saved data. The Android SDK will be in a similar state as after application restart.
In case of failure, a OneginiResetError
will be returned.
public void reset() {
OneginiSDK.getOneginiClient(this).reset(new OneginiResetHandler() {
@Override
public void onSuccess(@NotNull final Set<UserProfile> removedUserProfiles) {
removeUserProfiles(removedUserProfiles);
}
@Override
public void onError(@NotNull final OneginiResetError error) {
@OneginiResetError.ResetErrorType final int errorType = error.getErrorType();
if (errorType == OneginiInitializationError.DEVICE_DEREGISTERED) {
// Reset failed due to missing device credentials. Register app once again.
new DeregistrationUtil(DashboardActivity.this).onDeviceDeregistered();
}
}
private void removeUserProfiles(final Set<UserProfile> removedUserProfiles) {
for (final UserProfile userProfile : removedUserProfiles) {
userStorage.removeUser(userProfile);
}
}
});
}