Home > Blockchain >  Issue with Application Packaging in Kotlin
Issue with Application Packaging in Kotlin

Time:05-21

I have an app I built, deployed and is being tested with Google Developer Tester Option. My app(s) i have been developing has a wierd issue I can not put my finger on.

The App is a simple Note Taking App. So there is not a lot of code. I done my main activity only has about 60 lines of code. Everything else is composed of classes.

When I test my app on my cellphone. There is a time delay of 5 seconds that a white screen shows while launching. Then it goes to the app.

I would usually put a splash screen. And its seamless in loading. Without the splash screen with normal code it shows the white screen for 5 seconds.

My question is, am I doing something or wrong or is this something with the transition of .apk to .aab when packaging?

I have read articles of people saying its a bug withing Android itself. I have no warnings or errors within the app.

This has me puzzled and any advice would be helpful.

Here is a screenshot of the start up process.

enter image description here

Then this happens for 5 seconds then the main app shows

enter image description here

Any help is appreciated.

CodePudding user response:

Your application can't launch instantly, the time it takes to launch an application depends on several hardware factors. So the launch time is different from one smartphone to another

https://developer.android.com/topic/performance/vitals/launch-time

CodePudding user response:

Ok after some test coding I finally solved the issue. To have the White Screen not appear you can create a splash screen or just a theme.

Theme should be set as follows

<style name="Theme.SplashScreen" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowDisablePreview">true</item>
</style>

Then in your SplashScreen.kt you can add the following

val handler = Handler(Looper.getMainLooper())
    handler.postDelayed({
        val intent = Intent(this, MainActivity::class.java)
        startActivity(intent)
        finish()
    }, 2000)

Then in your Manifest you need add the following:

<activity
        android:name=".SplashScreen"
        android:exported="true"
        android:theme="@style/Theme.SplashScreen">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:exported="true">

    </activity>

This cuts the launch time with the Splash Screen to whatever your delay is set at.

  • Related