I am catering for two specific scenarios
As I need to customise with how Views are loaded I have implemented a Custom View Presenter (MvxAndroidViewPresenter) see SplitViewPresenter presentation
For scenario 2 I pass some PresentationValues in the Request to signal that I want to do something different when showing the LoginView
if (request.PresentationValues != null && request.PresentationValues.ContainsKey(MakeViewTopHint.HintName))
{
intent.AddFlags(ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.ClearTask);
}
This causes the the stack do be unwound and the LoginView is shown. Great.
For scenario 1 I use a BroadcastReceiver to catch the Intent, ActionScreenOff. Then I try to show the same Activity that was previously shown with a NewTask and ClearTask.
Scenario 1 works fine if I remove the NewTask and ClearTask flags used for Scenario 2 but I need them to clear the back stack down.
Does anyone know why the use of NewTask and ClearTask would be preventing the Activity from being shown subsequently
The problem was MVVMCross's MvxAndroidViewsContainer.AdjustIntentForPresentation. It sets the NewTask ActivityFlag on the Intent that is used for Scenario 1.
In fairness there is probably a good reason for this but when NewTask is used to start an Activity after previously starting that Activity with NewTask and ClearTask it will not resolve and the Activity is not displayed.
Thanks to MVVMCross' almost limitless configurability I am able to create a custom AndroidViewsContainer. When Scenario 1 is being played out I ensure that the NewTask flag is not used and everything works.
The issue of ActivityFlags.NewTask preventing the Activity from being resolved is not an MVVM cross or Xamarin thing as I can now repro, what I consider to be odd behavior, in vanilla Android.
I now have a working solution to both scenarios