Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

XF Android app crashes on 1st retart after exit.

$
0
0

This is what is happening:

  1. Start the app.
  2. Exit the app by tapping on the Back key.
  3. Restart the app by tapping on its icon.
  4. Booooom - a Java language Runtime Exception occurs. The error lines are given below.
  5. Again restart the app by tapping on its icon.
  6. Now no problem...the app starts normally without any error.

The error lines shown are:

  1. A Java.Lang.RuntimeException was thrown.
  2. java.lang.reflection.InvocationTargetException
  3. (line) 33 MyProjectName.Android.MainActivity.OnCreate (Android.OS.Bundle) [0x00080]

My code of OnCreate() is (Line just before #endregion is the line 33):

        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            #region Resolver Init
            SimpleContainer container = new SimpleContainer();
            container.Register<IDevice>(t => AndroidDevice.CurrentDevice);
            container.Register<IDisplay>(t => t.Resolve<IDevice>().Display);
            container.Register<INetwork>(t => t.Resolve<IDevice>().Network);

            Resolver.SetResolver(container.GetResolver());
            #endregion

            global::Xamarin.Forms.Forms.Init (this, bundle);

            LoadApplication (new App ());
        }

Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>