Auto-initialize your android library

I’ve been writing a couple of android libraries open and closed source ones. At one point, a library(not all of them, but a few) need a context to initialise, which is not such an easy task to achieve since the first time that the context is available is in the onCreate method of the Application Object. That’s why many libraries have an init method, which you have to call in the applications Application Object. In this article I’ll show you another way of doing it.

So I guess many of you have seen something like this before:




Android Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Bottom Navigation View With Fragments (No fragment re-creation).

Multiple Runtime Permissions in Android Without Any Third-Party Libraries

Addressable TV

Jetpack Compose under the hood: Touch Events

Biometric Security in Android Applications

Custom Gradle Tasks with Kotlin

Back press handling with AndroidX Navigation component

Creating android binding library in xamarin with multiple binaries

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
André Tietz

André Tietz

Android Developer

More from Medium

Simple Android Network Traffic Inspection With Chucker And Seismic

Worms Eye View From Spiral colored decore glass through a roof

Wireless Debugging — Android Apps

Exploring Android 12: BiometricPrompt Localizable Strings

Android 13: Notification Runtime Permission