Agregue el siguiente método a su clase i MainActivity.java
.
private void startResetFlow() {
LOGGER.debug("starting Reset flow");
StoreHelper.reset();
// Creating flow and configuring steps
Flow flow = new Flow("reset");
flow.setSteps(new Step[]{
new StoreManagerStep(), // clears the application store (APP_SECURE_STORE)
new BasicAuthStep(), // removes any saved cookies
new PasscodePolicyStoreStep() // clears the passcode policy store (RLM_SECURE_STORE) and creates a new one
});
// Preparing flow context
flowContext.setContext(this.getApplication());
flowContext.setFlowPresentationActionHandler(new FlowPresentationActionHandlerImpl(this));
flowManagerService.execute(flow, flowContext, new FlowActionHandler() {
@Override
public void onFailure(Throwable t) {
LOGGER.debug("Reset failed. ");
showAlertDialog("Reset", t);
}
@Override
public void onSuccess(FlowContext result) {
LOGGER.debug("Successfully reset");
// show splash screen again then start onboarding flow
getSupportActionBar().hide();
setContentView(R.layout.splash_screen);
// After the reset, the stores should be empty
LOGGER.debug("About to log values from the Passcode Policy Store");
StoreHelper.logStoreValues(((OnboardingContext) result).getPasscodePolicyStore());
LOGGER.debug("About to log values from the Application Store");
StoreHelper.logStoreValues(((OnboardingContext) result).getApplicationStore());
startOnboardingFlow();
}
});
}
El método adicional llama al StoreHelper's
un método de reinicio que borra los datos de las tiendas y luego inicia el flujo a bordo.
Agregue la siguiente línea al onReset
método.
startResetFlow();
Dentro de showAlertDialog
método, combine el siguiente código.
if (t.getMessage().equals("Eula Rejected") || flow.equals("Onboard")) {
startResetFlow();
}
Esto asegurará que si el EULA es rechazado o falla a bordo, el flujo a bordo se reanudará.