title: How should I create the main activity on android with xamarin forms in order to support PiP mode?
body: <p>I’m have an app developed with Xamarin forms and my users want to be able to use it with PIP modes of Android. I have tried integrate it but when app is resized, main activity of android call onCreate method again when app is just running so then app is frozen and it crashes. And in addition, the app is started from beginning.
  So, I have tried to search information about how I should developed it, but I don’t find information about this. Could you give me some tips or samples about how I should create the main activity on android in order to Xamarin Forms works correctly with PIP mode?
  Thank you </p>
  
  <p>I have tried with a blank Project... nothing. when I saw that the onCreate Method is called… I tried to create only one time the Core App() in order to "continue" WHERE it is, but it is frozen.</p>
  
  <pre><code>public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
  {
      protected override void OnCreate(Bundle savedInstanceState)
      {
          TabLayoutResource = Resource.Layout.Tabbar;
          ToolbarResource = Resource.Layout.Toolbar;
  
          base.OnCreate(savedInstanceState);
          var x = typeof(Xamarin.Forms.Themes.DarkThemeResources);
          x = typeof(Xamarin.Forms.Themes.Android.UnderlineEffect);
          global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
          CachedImageRenderer.Init(true);
          FFImageLoading.ImageService.Instance.Initialize(new Configuration());
          ZXing.Net.Mobile.Forms.Android.Platform.Init();
          ZXing.Mobile.MobileBarcodeScanner.Initialize(this.Application);
          Xamarin.Forms.DependencyService.Register&lt;ToastNotification&gt;(); // Register your dependency
          ToastNotification.Init(this);
          LoadApplication(TVOnlineSpain.App.Instance);
          ……….
      }
      ……….
  }
  </code></pre>
  
  <p>I would like to app continue the state (in my case more frequent, playing video on a page of xamarin forms) While user can change to size of activity changing the full screen or using the native PIP mode, instead of crash it. Could you give me some advice about how to avoid this problem? Thank you </p>