Fixed
Status Update
Comments
ub...@gmail.com <ub...@gmail.com> #2
Can you explain your use case?
ba...@gmail.com <ba...@gmail.com> #3
I am using Safe Args from Navigation and also using SavedStateHandle to pass in arguments from the args bundle to my ViewModel. This gives me access to them through the constructor. Unfortunately I then have to use string keys to get values out of the SavedStateHandle instead of using the generated SafeArgs.
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #4
Dagger Hilt has been released in alpha. It greatly simplifies SavedStateHandle injection into ViewModel. Soon more and more people would want this feature.
il...@google.com <il...@google.com> #5
Currently the combination of Hilt, SavedStateHandle and Safe args is not possible. The closest I've seen is to drop using safe args and just use magic strings. This also not ideal re dependency inversion as now you have to construct a mock SavedStateHandle for unit tests etc.
class ArticleViewModel @ViewModelInject constructor(
private val repository: ArticleRepository,
@Assisted savedStateHandle: SavedStateHandle
) {
// FIXME: oops, magic "articleId" string
private val articleId: Long = savedStateHandle["articleId"]
?: throw IllegalArgumentException("Article ID required")
}
Description
Version used: 1.1.0
Devices/Android versions reproduced on: Emulator API 19
Activity.reportFullyDrawn() was introduced in API 19 but has a bug at that API level requiring the system permission UPDATE_DEVICE_STATS, which is not available to non-system apps. FragmentActivity could override the method and do nothing on API 19 and below. This avoids running into the unfixable bug, and also avoids having to do API-specific code wrapping for API 18 and below where the method does not exist.