Example:
public class ClearBackstackHint : MvxPresentationHint
{
public string ActivityName { get; set; }
public ClearBackstackHint(string activityName = "mainactivity")
{
ActivityName = activityName;
}
}
public class BackStackHintHandler
{
Context _applicationcontext;
Type _mainActivityType;
public BackStackHintHandler(Context applicationcontext, Type mainActivityType)
{
_applicationcontext = applicationcontext;
_mainActivityType = mainActivityType;
}
public bool HandleClearBackstackHint(ClearBackstackHint clearBackstackHint)
{
Intent i = new Intent(_applicationcontext, _mainActivityType);
i.SetFlags(ActivityFlags.NewTask | ActivityFlags.SingleTop | ActivityFlags.ClearTop);
_applicationcontext.StartActivity(i); // Launch the mainActivity instance on top and stack after mainActivity
return true;
}
}
in your app setup
BackStackHintHandler _backStackHandler;
/// <summary>
/// Creates the view presenter.
/// </summary>
/// <returns>The view presenter.</returns>
protected override IMvxAndroidViewPresenter CreateViewPresenter()
{
var presenter = base.CreateViewPresenter();
_backStackHandler = new BackStackHintHandler(ApplicationContext, typeof(RootView));
presenter.AddPresentationHintHandler<ClearBackstackHint>(_backStackHandler.HandleClearBackstackHint);
return presenter;
}
After, you can call await _navigationService.ChangePresentation(new ClearBackstackHint());
aren't github issues should be limited to feature request/actual bugs found within MVVMCross ?
this kind of questions should be asked on xamarin slack/ stackoverflow
@iqbalmineraltown I don't think @RonakPatel21 was asking a question, just didn't realise you could already do it with mvvmcross.
@RonakPatel21 can you confirm @Thetyne 's example addresses what you want to do?
@Thetyne: Do you also have a solution for iOS? Thanks in advance.
Most helpful comment
Example:
in your app setup
After, you can call
await _navigationService.ChangePresentation(new ClearBackstackHint());