Reputation: 622
I'm trying to store class type as a member variable in my android application, so that I can go to that activity next.
I am using Class of Any
, but I don't know why it is not accepting type of any class, which means anything.
val state : MutableLiveData<Pair<State,Class<Any>>>
= MutableLiveData(Pair(State.Initial,MainActivity::class.java))
Can anyone help me resolving this issue ?
Upvotes: 0
Views: 87
Reputation: 30755
Try to use out
modifier for generic type:
val state : MutableLiveData<Pair<State, Class<out Any>>>
= MutableLiveData(Pair(State.Initial, MainActivity::class.java))
out
modifier is used in Kotlin to indicate covariance (similar to ? extends T
in Java).
Upvotes: 3