我们使用View Presenter清除后堆栈。下面的代码用于实现该目标,并且效果很好。从MvvmCross 5.2开始,显示(意图)不再存在。我们应该用什么代替呢?

public class ViewPresenter : MvxAndroidViewPresenter
{
    public override void Show(MvxViewModelRequest request)
    {
        if (request != null && request.PresentationValues != null)
        {
            if (request.PresentationValues.ContainsKey(ShowViewParameters.ClearBackstack.ToString()))
            {
                // Get intent from request and set flags to clear backstack.
                var intent = base.CreateIntentForRequest(request);
                intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask);

                base.Show(intent);
                return;
            }
        }

        base.Show(request);
    }
}

最佳答案

这是我现在编写的程序,它可以正常工作:

public class ViewPresenter : MvxAndroidViewPresenter
{
    public ViewPresenter(IEnumerable<Assembly> androidViewAssemblies) : base(androidViewAssemblies)
    {
    }

    public override void Show(MvxViewModelRequest request)
    {
        var intent = base.CreateIntentForRequest(request);

        if (request != null && request.PresentationValues != null)
        {
            if (request.PresentationValues.ContainsKey(ShowViewParameters.ClearBackstack.ToString()))
            {
                // Get intent from request and set flags to clear backstack.
                intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask);
            }
        }

        ShowIntent(intent);
    }
}

关于android - MvvmCross Show(intent)不再可用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46350933/

10-09 09:51