I had the same problem. Just run a custom presenter that sets some flags of intent if you want to achieve this:
public class CustomAndroidPresenter : MvxAndroidViewPresenter { public override void Show(MvxViewModelRequest request) { if (request != null && request.PresentationValues != null) { if (request.PresentationValues.ContainsKey("MyCustomFlag")) {
Then you need to set this leading to your settings class:
protected override IMvxAndroidViewPresenter CreateViewPresenter() { var presenter = new CustomAndroidPresenter(); Mvx.RegisterSingleton<IMvxViewPresenter>(presenter); return presenter; }
And then, to show the viewmodel (for example, your login-view), simply set your key-code-key, which the host knows that he must set inten-flags:
protected void ShowViewModel<TViewModel>(bool clearbackstack) where TViewModel : MvxViewModel { if (clearbackstack) { var presentationBundle = new MvxBundle(new Dictionary<string, string> { { "MyCustomFlag", "" } }); ShowViewModel<TViewModel>(presentationBundle: presentationBundle); return; }
To show the view mode (without reverse navigation), simply use the following code:
ShowViewModel<MyViewModel>(true);
And then, when you click the "Back" button, you cannot return to the previous action, since the stop memory will be deleted.
source share