Mvvm Cross android Application takes 2 seconds to launch splash screen

I am newbie to xamarin and mvvm cross. Recently i am developing an app. the android app takes 2-3 seconds to launch the splash screen after the application icon is clicked.I am loading 20 Nuget packages like Mvvm cross and Microsoft appcenter etc. I run the app in the redmi note 5 pro and the android version is 8.1 and i checked in another device then it takes more time approximately 5 seconds.Please any one replay ASAP

Answers

  • ivanxamarinivanxamarin Member ✭✭
    edited December 2018

    Xamarin Forms apps do need some time to start. Your problem with splash screen might be that your first activity doesn't have a background and you see your first activity after a few seconds. Did you set background to your splash theme? It should look something like this:

    styles.xml:

    < style name="MyTheme.Splash" parent ="Theme.AppCompat.Light.NoActionBar" >
        < item name="android:windowTranslucentStatus" >true< /item >
        < item name="android:windowTranslucentNavigation" >true< /item >
        < item name="android:windowBackground" > @drawable/splash_screen < /item >
        < item name="android:windowNoTitle" >true< /item >
        < item name="android:windowFullscreen" >false< /item >
      </style>
    

    splash_screen.xml:

    < ?xml version="1.0" encoding="utf-8"? >
    < layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
      < item >
        < color android:color="#8ceb8c" />
      < /item >
      < item >
        < bitmap
            android:src="@drawable/screen"
            android:gravity="fill" />
      < /item >
    < /layer-list >
    

    and

    SplashActivity.cs:
    [Activity(Label = "MyApp", Icon = "@drawable/ic_launcher", Theme = "@style/MyTheme.Splash", MainLauncher = true)]
        public class SplashActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    
  • harsha1996harsha1996 Member ✭✭

    Thanks for reply Ivan, I had SplashScreen provided by MVVM Cross. It takes 3 seconds to startup in redmi note 5 pro.I enabled AotAssemblies and EnableLLVM in release mode.but it dosen't show any changes.So how to improve performance.

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    You could add some log to find out which part consume so much time in your project. And avoid doing much work in your Activity OnCreate() method.

Sign In or Register to comment.