我们使用ViewPresenter清除后台堆栈。下面的代码用于实现这一点,并且运行良好。由于MvvmCross 5.2 Show(intent)不再存在。我们应该用什么呢?
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);
}
}
答案 0 :(得分:1)
这是我现在编程的,它运行良好:
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);
}
}