The Frontier logo The Frontier logo
Mark Allison

Kotlin and Android Lifecycles

Mark Allison | May 28, 2018

What are some strategies for dealing with Kotlin and Android Lifecycles?

In this screencast, cast you'll learn how Android Lifecycles appear to inhibit some core behaviors of Kotlin. For very good reasons Kotlin favors:

- Initialization of properties at the point where they are declared
- That we should try to avoid using nullable variables wherever possible
- That we should strive for immutability wherever possible.

Adhering to these principles appears to be difficult when we are operating within an Android lifecycle, such as an Activity, where often we cannot initialize properties until onCreate() because the Activity is not valid before that point. During this video, we’ll look at some strategies for overcoming these difficulties.

Supported Links:

Lateinit Modifier Documentation

Lazy Delegate Documentation

Kotlin Programming by Big Nerd Ranch