Source:
<code>@Override public void changeKey(@Nullable State outgoingState, State incomingState, <START> Flow.Direction direction, Context incomingStateContext, Flow.TraversalCallback callback) { <END> final Object mainContent; final Object dialogContent; final Object showThis = incomingState.getKey(); if (showThis instanceof DialogScreen) { final DialogScreen dialogScreen = (DialogScreen) showThis; mainContent = dialogScreen.mainContent; dialogContent = dialogScreen.dialogContent; } else { mainContent = showThis; dialogContent = null; } final TextView mainView = new TextView(MultiKeySampleActivity.this); if (mainContent instanceof ScreenOne) { mainView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getFlow().set(new DialogScreen(mainContent, new DialogContent())); } }); } else { mainView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getFlow().set(new ScreenOne()); } }); } mainView.setText(mainContent.toString()); setContentView(mainView); hideOldDialog(); if (dialogContent != null) { visibleDialog = new AlertDialog.Builder(MultiKeySampleActivity.this) .setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { getFlow().goBack(); } }) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { getFlow().goBack(); } }) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { getFlow().set(new ScreenTwo()); } }) .setTitle(dialogContent.toString()) .show(); } callback.onTraversalCompleted(); }</code><technical_language>a single Context sense multikeys</technical_language>

Target:
@Override public void changeKey(@Nullable State outgoingState, State incomingState, Flow.Direction direction, Context incomingStateContext, Flow.TraversalCallback callback) { final Object mainContent; final Object dialogContent; final Object showThis = incomingState.getKey(); if (showThis instanceof DialogScreen) { mainContent = ((DialogScreen) showThis).mainContent; dialogContent = showThis; } else { mainContent = showThis; dialogContent = null; } final TextView mainView = new TextView(MultiKeySampleActivity.this); if (mainContent instanceof ScreenOne) { mainView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getFlow().set(new DialogScreen(mainContent)); } }); } else { mainView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getFlow().set(new ScreenOne()); } }); } mainView.setText(mainContent.toString()); setContentView(mainView); dismissOldDialog(); if (dialogContent != null) { visibleDialog = new AlertDialog.Builder(MultiKeySampleActivity.this) .setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { getFlow().goBack(); } }) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { getFlow().goBack(); } }) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { getFlow().set(new ScreenTwo()); } }) .setTitle(dialogContent.toString()) .show(); getApplication().registerActivityLifecycleCallbacks(new ActivityLifecycleCallbackAdapter() { @Override public void onActivityDestroyed(Activity activity) { getApplication().unregisterActivityLifecycleCallbacks(this); dismissOldDialog(); } }); } callback.onTraversalCompleted(); }