Category "android-viewmodel"

How can I passs a method except parameter in Kotlin?

I hope to pass a method which implement MediaRecorder.OnInfoListener. At present I use Code A to pass the method which implement MediaRecorder.OnInfoListener.

Sharing viewModel within Jetpack Compose Navigation

Can anyone suggest how to share a ViewModel within different sections of a Jetpack Compose Navigation? According to the documentation, viewModels should normall

How ViewModel is not get destroyed when activity is rotated

I am curious to know how a ViewModel survives when Activity gets rotated because of that it destroyed and recreated again. Logically If we see then ViewModel ge

Why recomposition happens when call ViewModel in a callback?

I completely confused with compose conception. I have a code @Composable fun HomeScreen(viewModel: HomeViewModel = getViewModel()) { Scaffold { val

Manually clearing an Android ViewModel?

Edit: This question is a bit out of date now that Google has given us the ability to scope ViewModel to navigation graphs. The better approach (rather than tryi

how to get viewModel by viewModels? (fragment-ktx)

I am working with Single viewModel for the Activity and all of it's fragment. So to initialise viewmodel if have to write this setup code in onActivityCreated

how can i share viewModel between Activities?

I'm learning Android ViewModel now. and I have MainActivity and RegisterActivity which can type name, age, and phone number in there. after typing that informat

Unit test the new Kotlin coroutine StateFlow

Recently, the class StateFlow was introduced as part of Kotlin coroutines. I'm currently trying it and encountered an issue while trying to unit test my ViewMod

Unit test the new Kotlin coroutine StateFlow

Recently, the class StateFlow was introduced as part of Kotlin coroutines. I'm currently trying it and encountered an issue while trying to unit test my ViewMod

Retrofit call in Kotlin Coroutines viewModelScope

Recently I've updated my ViewModel to use new viewModelScope. From its implementation, I see that Dispatchers.Main.immediate is set as the default CoroutineDisp

Retrofit call in Kotlin Coroutines viewModelScope

Recently I've updated my ViewModel to use new viewModelScope. From its implementation, I see that Dispatchers.Main.immediate is set as the default CoroutineDisp

AbstractSavedStateViewModelFactory: SavedStateProvider with the given key is already registered

Although it is the same exception, my situation is different from SavedStateProvider with the given key is already registered as I am using Nav-graph Scoped Vie

How to use navGraphViewModels in Activity (Not in Fragment)

In Fragment, we can use ViewModel scoped to navigation Graph. private val viewModel: ViewModel by navGraphViewModels(R.id.youNavGraphID) But how to create View

My observer is always firing when I come back from one fragment to another

I'm using Navigation Components, I have Fragment A and Fragment B, from Fragment A I send an object to Fragment B with safe args and navigate to it. override f