Questions regarding applying a Model-View-ViewModel in android application
Questions tagged [android-mvvm]
773 questions
2
votes
2 answers
Performing single shot operations using SharedFlow without casting to needed value
I have the following SharedFlow in my viewmodel -
class HeroesViewModel(private val heroesRepositoryImpl: HeroesRepositoryImpl) : ViewModel() {
private val _uiState = MutableStateFlow(UiState())
val uiState = _uiState.asStateFlow()
…

Alon Shlider
- 1,187
- 1
- 16
- 46
2
votes
1 answer
Dagger hilt Cannot be provided without an @Provides-annotated method
I am new with dagger using. So, I can't solve whats the problem with this. I just want to ask here to solve it.
This is the…

Ahmet Yılmaz
- 57
- 1
- 11
2
votes
2 answers
Jetpack Compose LazyColum state not changing when changes are made inside of containing objects
Below is a simple Cart Implementation where the value of qty should increase by 1 if a list item is clicked...
But somehow values in the ViewModel are changing, but not reflected in UI ( not recomposing with new qty value)
I think problem lies in…

Sharukh Rahman
- 327
- 3
- 12
2
votes
2 answers
MutableStateFlow is triggered after returning to the app
In my MainActivity I have BottomNavigation. My activity is connected with MainViewModel. When app starts I fetch data from firebase. Until the data is downloaded, app displays ProgressBar and BottomNavigation is hide (view.visibility = GONE). When…

Wafi_ck
- 1,045
- 17
- 41
2
votes
2 answers
What are the states of activity while rotating the screen with using ViewModel?
If we rotate the screen activity will recreate, but if we use ViewModel values will be retain. So the question is, if we have used ViewModel and we rotate the screen, will our activity recreate and call onCreate, onStart, onResume?

Aditya Vyas-Lakhan
- 13,409
- 16
- 61
- 96
2
votes
1 answer
Return value from a CorutineExectionHandler to the calling method
Is it possible to return value from the CoroutineExceptionHandler to the calling method?
override suspend fun getStatus() : Model {
return withContext(Dispatchers.IO + errorHandler) {
//Do something and return model
…

abhishek maharajpet
- 482
- 1
- 4
- 18
2
votes
2 answers
Handle search results after configuration change MVVM
I am building a movie app based on "The Movie DB". My app has only one activity with a recyclerview and one search action button (SearchView).
As soon as the app starts,the recyclerview filled with popularMovies list.
When I search for a movie I get…

HoLoGram
- 167
- 10
2
votes
0 answers
Bound Services in MVVM pattern
I'm working on an Android app (in Java) and trying to use Google's recommended application architecture, but I can't seem to figure out where services fit in to this architecture. I've done a lot of looking online and there is no clear consensus on…

Jeff L
- 491
- 5
- 14
2
votes
0 answers
ViewModel factory returns new instances instead of existing one
I am using
class MyViewModelFactory(
private val app: Application,
private val someClass: SomeClass,
) : ViewModelProvider.Factory {
@Suppress("unchecked_cast")
override fun create(modelClass: Class): T…

Pavel Poley
- 5,307
- 4
- 35
- 66
2
votes
1 answer
In Android, Make a list of api call inside one api call
In one of my android app, at first I want to call an api, which will return a list of item, and the item will be shown in a RecyclerView. I also need to call another api for each item of the RecyclerView to fetch description of that item and show…

Aminul Haque Aome
- 2,261
- 21
- 34
2
votes
3 answers
Initiating a ViewModel with Input parameters in Jetpack Compose -> Composable function
I have a ViewModel that takes a string as an argument
class ComplimentIdeasViewModel(ideaCategory : String) : ViewModel() {
//some code here
}
What is the best way to initiate this ViewModel inside a composable fun without using a ViewModel…

Anudeep Ananth
- 955
- 1
- 8
- 30
2
votes
0 answers
Add views to activity at runtime using MVVM in Android
I have many activities in my application. Each activity has many UI elements like EditText, TextView, DatePicker, DropDown etc. Activity has both static components (views statically placed in xml layout) and dynamic components (views added at…

Rakesh
- 1,205
- 1
- 14
- 33
2
votes
1 answer
Flow data is not showing in jetpack compose
I'm trying to get data from server and cache into database and return new fetched list to user. I'm getting response form server and saving it to the local database but when im trying to observer it from composable function it showing list is…
user15301088
2
votes
2 answers
Why each activity is getting update to the original live data instead of recent live data?
MeetingViewModel
fun observeAttendeesJoined(): LiveData>? {
return Repository.getAttendeesJoined()
}
There is a singleton repository using kotlin's object declaration.
Repository has a live data which is being…

Sagar Patel
- 506
- 1
- 8
- 23
2
votes
1 answer
Communication between ViewPager's host Fragment and ViewPager's Fragment item
I have a Fragment(InsiraDocumentosFragment) that has a viewpager and in that fragment I initialize an adapter(InsiraDocumentoAdapter) to initialize the viewpager.
The adapter(InsiraDocumentoAdapter) initializes generic fragments (DocumentoFragment)…

Lucas Kloss Teles
- 33
- 5