title: Lifecycle of fragments in mvvmCross
body: <p>I have the following problem when using fragments in mvvmCross. I borrowed the code from <a href="https://github.com/slodge/MvvmCross-Tutorials/tree/master/Fragments" rel="nofollow">https://github.com/slodge/MvvmCross-Tutorials/tree/master/Fragments</a>. The Framepresenter Class which is in <a href="https://github.com/slodge/MvvmCross-Tutorials/blob/master/Fragments/FragmentSample.UI.Droid/Setup.cs" rel="nofollow">https://github.com/slodge/MvvmCross-Tutorials/blob/master/Fragments/FragmentSample.UI.Droid/Setup.cs</a> resolved requests to show viewmodels in the show method</p>
  
  <pre>
   public class CustomPresenter
          : MvxAndroidViewPresenter
          , ICustomPresenter
      {
          private Dictionary _dictionary = new Dictionary();
  
          public override void Show(MvxViewModelRequest request)
          {
              IFragmentHost host;
              if (_dictionary.TryGetValue(request.ViewModelType, out host))
              {
                  if (host.Show(request))
                  {
                      return;
                  }
              }
  
              base.Show(request);
          }
  ...
  </pre>
  
  <p>In the first run all works well. If I close the app with the "Back" Button of android and open it again I will get a null pointer exception in the Show method of the base class (MvxAndroidViewPresenter). This is because the top level activity does not exist any more. The property Activity in MvxAndroidViewPresenter is returning null. How can I recreate the top level activity when restarting the app?</p>
  
  <p>I get the following exception</p>
  
  <pre>
  06-26 16:06:28.102 I/MonoDroid( 6791): UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.Droid.Views.MvxAndroidViewPresenter.Show (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest) [0x0000f] in d:\Projekte\MvvmCross\mvvmcross-20130621\Cirrious\Cirrious.MvvmCross.Droid\Views\MvxAndroidViewPresenter.cs:29
  06-26 16:06:28.102 I/MonoDroid( 6791): at ManCockpit.UI.Droid.CockpitFragmentPresenter.Show (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest) [0x00040] in d:\Projekte\ManCockpitV2\ManCockpit.UI.Droid\CockpitFragmentPresenter.cs:41
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.Droid.Views.MvxAndroidViewDispatcher/c__DisplayClass1.b__0 () [0x00000] in d:\Projekte\MvvmCross\mvvmcross-20130621\Cirrious\Cirrious.MvvmCross.Droid\Views\MvxAndroidViewDispatcher.cs:27
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.Droid.Views.MvxAndroidViewDispatcher.ShowViewModel (Cirrious.MvvmCross.ViewModels.MvxViewModelRequest) [0x00015] in d:\Projekte\MvvmCross\mvvmcross-20130621\Cirrious\Cirrious.MvvmCross.Droid\Views\MvxAndroidViewDispatcher.cs:27
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.ViewModels.MvxNavigatingObject.ShowViewModelImpl (System.Type,Cirrious.MvvmCross.ViewModels.IMvxBundle,Cirrious.MvvmCross.ViewModels.IMvxBundle,Cirrious.MvvmCross.ViewModels.MvxRequestedBy) 
  06-26 16:06:28.102 I/MonoDroid( 6791): at (wrapper dynamic-method) objec06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.ViewModels.MvxNavigatingObject.ShowViewModel (System.Type,Cirrious.MvvmCross.ViewModels.IMvxBundle,Cirrious.MvvmCross.ViewModels.IMvxBundle,Cirrious.MvvmCross.ViewModels.MvxRequestedBy) 
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.ViewModels.MvxNavigatingObject.ShowViewModel (Cirrious.MvvmCross.ViewModels.IMvxBundle,Cirrious.MvvmCross.ViewModels.MvxBundle,Cirrious.MvvmCross.ViewModels.MvxRequestedBy) 
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.ViewModels.MvxAppStart`1.Start (object) 
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.Droid.Views.MvxSplashScreenActivity.TriggerFirstNavigate () [0x00007] in d:\Projekte\MvvmCross\mvvmcross-20130621\Cirrious\Cirrious.MvvmCross.Droid\Views\MvxSplashScreenActivity.cs:82
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.Droid.Views.MvxSplashScreenActivity.InitializationComplete () [0x00001] in d:\Projekte\MvvmCross\mvvmcross-20130621\Cirrious\Cirrious.MvvmCross.Droid\Views\MvxSplashScreenActivity.cs:76
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.Droid.Platform.MvxAndroidSetupSingleton.InitialiseFromSplashScreen (Cirrious.MvvmCross.Droid.Views.IMvxAndroidSplashScreenActivity) [0x00036] in d:\Projekte\MvvmCross\mvvmcross-20130621\Cirrious\Cirrious.MvvmCross.Droid\Platform\MvxAndroidSetupSingleton.cs:76
  06-26 16:06:28.102 I/MonoDroid( 6791): at Cirrious.MvvmCross.Droid.Views.MvxSplashScreenActivity.OnCreate (Android.OS.Bundle) [0x00014] in d:\Projekte\MvvmCross\mvvmcross-20130621\Cirrious\Cirrious.MvvmCross.Droid\Views\MvxSplashScreenActivity.cs:47
  06-26 16:06:28.102 I/MonoDroid( 6791): at ManCockpit.UI.Droid.SplashScreenActivity.OnCreate (Android.OS.Bundle) [0x0002e] in d:\Projekte\ManCockpitV2\ManCockpit.UI.Droid\SplashScreenActivity.cs:105
  06-26 16:06:28.102 I/MonoDroid( 6791): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/platforms/android-15/src/generated/Android.App.Activity.cs:1859
  06-26 16:06:28.102 I/MonoDroid( 6791): at (wrapper dynamic-method) object.08473369-0d89-4344-a57c-40e97793bab8 (intptr,intptr,intptr) 
  </pre>