Cookie Consent by Free Privacy Policy Generator ๐Ÿ“Œ Decrease startup time with Jetpack App Startup

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Decrease startup time with Jetpack App Startup


๐Ÿ’ก Newskategorie: Android Tipps
๐Ÿ”— Quelle: feedproxy.google.com

Posted by Yacine Rezgui, Developer Advocate and Rahul Ravikumar, Software Engineer

Jetpack image

Application startup time is a critical metric for any application. Users expect apps to be responsive and fast to load. When an application does not meet this expectation, it can be disappointing to users. This poor experience may cause a user to rate your app badly on the Play store, or even abandon your app altogether.

Jetpack App Startup is a library that provides a straightforward, performant way to initialize components at application startup. Both library developers and app developers can use App Startup to streamline startup sequences and explicitly set the order of initialization.

Apps and libraries often rely on having components (WorkManager, ProcessLifecycleObserver, FirebaseApp etc.) initialized before Application.onCreate(). This is usually achieved by using content providers to initialize each dependency. Instead of defining separate content providers for each component that needs to be initialized, App Startup lets you define initializers that share a single content provider. This significantly improves app startup time, usually by ~2ms per content provider. App Startup also helps you further improve startup performance by making it really easy to initialize components lazily. When App Startup goes stable, we will be updating our libraries like `WorkManager` and `ProcessLifecycle` to benefit from this as well.

App Startup supports API level 14 and above.

How to use it

Gradle setup

To use App Startup in your library or app, add the following dependency to your gradle file:

repositories {
    google()
    maven()
}

dependencies {
  implementation "androidx.startup:startup-runtime:1.0.0-alpha02"
}
Define an Initializer

To be able to use App Startup in your application, you need to define an Initializer. This is where you define how to initialize and specify your dependencies. Hereโ€™s the interface you need to implement:

interface Initializer<out T: Any> {
    fun create(context: Context): T
    fun dependencies(): List<Class<out Initializer<*>>>
}

As a practical example, hereโ€™s what an Initializer that initializes WorkManager might look like:

class WorkManagerInitializer : Initializer<WorkManager> {
    override fun create(context: Context): WorkManager {
        val configuration = Configuration.Builder()
            .setMinimumLoggingLevel(Log.DEBUG)
            .build()

        WorkManager.initialize(context, configuration)
        return WorkManager.getInstance(context)
    }
   
    // This component does not have any dependencies
    override fun dependencies() = emptyList<Class<out Initializer<*>>>()
}

Note: This example is purely illustrative. This Initializer should actually be defined by the WorkManager library.

Lastly, we need to add an entry for WorkManagerInitializer in the AndroidManifest.xml:

<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    android:exported="false"
    tools:node="merge">
    <!-- This entry makes WorkManagerInitializer discoverable. -->
    <meta-data android:name="com.example.WorkManagerInitializer"
          android:value="androidx.startup" />
</provider>

How it works

App Startup uses a single content provider called InitializationProvider. This content provider discovers initializers by introspecting the <meta-data> entries in the merged AndroidManifest.xml file. This happens before Application.onCreate().

After the discovery phase, it subsequently initializes a component after having initialized all its dependencies. Therefore, a component is only initialized after all its dependencies have been initialized.

Lazy initialization

We highly recommend using lazy initialization to further improve startup performance. To make initialization of a component lazy, you need to do the following:

Add a tools:node="remove" attribute to the <meta-data> entry for the Initializer. This disables eager initialization.

<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    android:exported="false"
    tools:node="merge">
    <!-- disables eager initialization -->
    <meta-data android:name="com.example.WorkManagerInitializer"
              tools:node="remove" />
</provider>

To lazily initialize WorkManagerInitializer you can then use:

// This returns an instance of WorkManager
AppInitializer.getInstance(context)
    .initializeComponent(WorkManagerInitializer.class);

Your app now initializes the component lazily. For more information, please read our detailed documentation here.

Final thoughts

App Startup is currently in alpha-02. Find out more about how to use it from our documentation. Once you try it out, help us make it better by giving us feedback on the issue tracker.

...



๐Ÿ“Œ Decrease startup time with Jetpack App Startup


๐Ÿ“ˆ 60.85 Punkte

๐Ÿ“Œ Whatโ€™s New with Android Jetpack and Jetpack Compose


๐Ÿ“ˆ 30.12 Punkte

๐Ÿ“Œ Uber Doesn't Decrease Drunk Driving, Finds New Study


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Uber Doesn't Decrease Drunk Driving, Finds New Study


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Can Cloud Security Decrease Breach Containment Costs?


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Increase or Decrease Computer Volume With Keyboard Software


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Can Cloud Security Decrease Breach Containment Costs?


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Increase or Decrease Volume Of Multiple WAV Files Software


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Australian telco complaints to TIO continue to decrease despite rise in mobile issues


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ How To Increase Or Decrease Desktop Icon Spacing On Windows 10


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ How To Increase Or Decrease Desktop Icon Spacing On Windows 10


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Apple Fears Profit Decrease Because of China Tariffs. Trump Welcomes Apple Home.


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Senate Passes Cybersecurity Bill To Decrease Grid Digitization, Move Toward Manual Control


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Hamsters QA team is trying to decrease the number of unconfirmed bug reports in LibreOffice's Bugzilla right now


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Doing Five Things Could Decrease Your Risk of Alzheimer's By 60%


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ CS:GO Recent performance decrease


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Upcoming Firefox Update Will Decrease Power Usage on macOS by Up To Three Times


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ A graph of OS usage among Stack Overflow developer surveys from 2017-2022. Why did Linux's popularity decrease so bad from 2020 to 2021?


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Microsoft Earnings Release FY23 Q2: 2% revenue increase, 12% profit decrease


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Neonicotinoids Disrupt Aquatic Food Webs and Decrease Fishery Yields, Says Study


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ How privacy can decrease safety


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Venafi Media Alert: Certificate Lifetimes Decrease Again, Increasing the Risk of Outages


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Decrease in Linux gaming on Steam.


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Teaching Children To Play Chess Found To Decrease Risk Aversion


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ The Modern Parent: How to Decrease Drawbacks and Increase Benefits of Internet and Tech


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ How can businesses decrease cyber insurance premiums while maintaining coverage?


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ UK Finance Reports Slight Decrease in FinTech Cyberattacks


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ iPhone 16 Plus battery life to decrease, claims dubious leak


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ Drastically decrease the size of your Docker application


๐Ÿ“ˆ 22.21 Punkte

๐Ÿ“Œ How AI Helps Decrease Diversity Biases in Recruitment


๐Ÿ“ˆ 22.21 Punkte











matomo