首页 > 解决方案 > App delay in launching the splashscreen in xamarin forms Android how to optimize the startup time

问题描述

I am working on xamarin forms and I am facing issue in app delay in launching, Delay in spashscreen how to figure it out. I reduced some loading time by using "asynchronous". But it still taking 19 secs in debug and 8 secs in release mode.

MainActivity:

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    private string AppId = "6e3837aead704cb38b34985422b4d712";//Androidhockeyapp:created hockey app by using(levevagewinphne@hotmail.com)

    protected override void OnCreate(Bundle bundle)
    {
        try
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

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

            InitPlugins(bundle);

            LoadApplication(new App());

        }
        catch (Exception ex)
        {

        }
    }

    public async Task InitPlugins(Bundle bundle)
    {
        try
        {
            await Task.Run(async () =>    // by putting this Task.Run only the Activity Indicator is shown otherwise its not shown.  So we have added this.
            {
                //////hockeyApp Collect crash report
                //CrashManager.Register(this, AppId);

                //////hockeyApp User metrics
                //MetricsManager.Register(Application, AppId);

                Rg.Plugins.Popup.Popup.Init(this, bundle);

                //CrossCurrentActivity.Current.Init(this, bundle);

                BarCodes.Init(() => (Activity)Forms.Context);
                CachedImageRenderer.Init(true);
                //if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                //{
                //    Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
                //    Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
                //    Window.SetStatusBarColor(Android.Graphics.Color.ParseColor("#454546"));
                //}
            }).ConfigureAwait(false);
        }
        catch (Exception ex)
        {

        }

    }
}

标签: c#xamlxamarinxamarin.formsxamarin.android

解决方案


推荐阅读