Questions regarding applying a Model-View-ViewModel in android application
Questions tagged [android-mvvm]
773 questions
4
votes
1 answer
Accessing ViewModel functions from within a RecyclerView adapter
I am new to Android development and working through some basic Android apps to learn more. I want to learn MVMM architecture best practices as early as possible and am curious how to best solve the following task: In a simple list app, my ViewModel…

John Harrington
- 1,314
- 12
- 36
4
votes
1 answer
Android GRPC client http call error io.grpc.StatusException: UNAVAILABLE: End of stream or IOException
Grettings,
I like to know about how to ressolve the following exception when calling a GRPC service built with NodeJS in the backend side, and deployed to internet using Repl.it.
The following is the message that i got during the ui tests:
…

Marlon López
- 460
- 8
- 21
4
votes
2 answers
How can firebase phone auth be implemented in view model?
I'm trying to add the Firebase Phone Authentication code inside a View Model using Kotlin. The problem is that the PhoneAuthProvider requires an activity. Does anyone know how can this code be implemented inside a View Model without the need of an…

Toufic Batache
- 762
- 10
- 24
4
votes
1 answer
Android jetpack compose observing a livedata
I have question regarding using observeAsState() to automatically populate a composable list view.
My composable looks like this
@Composable
fun getTopMovies() {
val topMovies by movieListViewModel.getTopMovies().observeAsState()
…

Jono
- 17,341
- 48
- 135
- 217
4
votes
1 answer
Android: Firebase Object is null when using kotlin flow
My problem is, that when I try to get a document out of my database, that this document aka the object is always null. I only have this problem when I use Kotlin Coroutines to get the document out of my database. Using the standard approach with…

Andrew
- 4,264
- 1
- 21
- 65
4
votes
1 answer
Is it a good practice to observeForever in Repository class? db+network paged list
Im building an app following architecture guidelines.Implemented room db caching + network.Need to get latest page number from separate entity.
My model:
@Entity(tableName = "top_rated_movie_page")
public class Top_Rated_Movies_Page…

Nikola Srdoč
- 311
- 4
- 14
4
votes
1 answer
Difference between viewmodelfactory and view model injection using activity module
I am wondering which one of below two approaches better suit my android application and the reasons for it.
First is using viewmodelfactory pattern and second is viewModelStoreProvider. Can anyone shed some light on these approaches?
First…

avltree
- 51
- 4
4
votes
1 answer
Where does FusedLocationProviderClient fit in MVVM on Android?
I am working on an Android application where I have to display weather data to users when they start the app. I'm following MVVM architecture and have successfully followed MVVM in all the use cases I have implemented including displaying data to…

Abdul Mateen
- 1,418
- 1
- 14
- 32
4
votes
1 answer
should viewmodel contains some business logic? Or create own services?
I learn MVVM in android. I can't understand why never mention services? Now my app looks like activity <-> viewmodel <-> repository <-> dao. For example i want to synchronize date from Firebase every 4 hours. Where i should check time and load data?

sergkk
- 118
- 10
4
votes
1 answer
appbar_scrolling_view_behavior not resolved at SwipeRefreshLayout databinding android
I try to add the app:layout_behavior="@string/appbar_scrolling_view_behavior" to the SwipeRefreshLayout but I don't know why i isn't resolved at XML layout although It works properly after running the codes. Does this matter with data binding and…

Omid Erfanmanesh
- 547
- 1
- 7
- 29
4
votes
2 answers
Android: Save FCM Notification to Room DB
I am using firebase FCM to get the notification. I want if the notification received, that should store in my RoomDatabase. Later on, when the user opens the app, then in notification section all notification will display.
I am using MVVM, I was…

Akash Chaubey
- 43
- 1
- 5
4
votes
2 answers
How to show LoadingState when using Room Livedata MVVM
so I'm coming from an MVP background...
What I'm basically trying to do is start a loadingView as soon as we start fetching the data from Room (SQLite), stop the loadingView when successful and all of that logic should be handled in my ViewModel…

Martin
- 1,159
- 10
- 34
4
votes
0 answers
Unable to display data from remote server using MVVM architecture in android
I am not able to parse json data from remote server. I am using MVVM architecture and volley library to parse json data. I tried to debug and the message says "An attempt to invoke virtual method has been made on a null object reference".
I thought…

Osama
- 55
- 7
4
votes
2 answers
How to create focus change listener with data binding
I am using following code for EditText focus change event and its working when I tap on one EditText to another EditText but fails when we tap outside the EditText .I have already added focusable="true"and focusableInTouchMode="true" but it does not…

Sam
- 571
- 1
- 6
- 22
4
votes
1 answer
Android LiveData observes stale data after navigating back
Question:
How can I prevent my livedata immediately receiving stale data when navigating backwards? I am using the Event class outlined here which I thought would prevent this.
Problem:
I open the app with a login fragment, and navigate to a…

Daniel Wilson
- 18,838
- 12
- 85
- 135