1 min readJun 28, 2020
Direct reference to Context from a ViewModel is a problem because ViewModel outlives the Context's lifecycle. However, this context argument here isn't stored in the ViewModel, it's a parameter that will only be used inside the Activity. The NavController access works by the same principle, and also does not leak, despite having a smaller lifecycle.