1,860 questions
0
votes
1
answer
73
views
Should I always initialize a viewmodel at the start? [closed]
Should I always initialize a viewmodel in the Activity, before onCreate() even, if it is needed later in the flow?
I do not know and am concerned if initialization of all the viewmodels right at the ...
0
votes
1
answer
124
views
Android: Filter CardViews in RecyclerView List with Room DAO
I have a RecylcerView List of CardViews. Each CardView holds user data that is saved in a Room database. Some of the CardViews have due dates that have been entered by the user with a TimePicker. I ...
0
votes
0
answers
44
views
NavGraph & viewmodel gets reset on each config change
I’m using a single activity app, where you have a Splash screen using the new splash screen api, keepsplashscreen is used to keep showing the splash screen till the check if the user is logged in or ...
1
vote
1
answer
39
views
How i persist email after navigating from current page and returning back?
the logic i wish to implement is that i'm current at my MagicLinkScreen where user enter email, if email is valid it forward user to another screen that open mails app. Now when i navigate back from ...
2
votes
1
answer
139
views
Jetpack Compose inside a Fragment: pass Fragment args directly to Composable or via ViewModel (SavedStateHandle)?
I’m migrating a Fragment-based app to Jetpack Compose incrementally. Some screens are still Fragments that host Compose with ComposeView. I recently changed a screen to pass a tabUid through Fragment ...
3
votes
2
answers
88
views
How to implement bidirectional syncing of text field input between a view model and a composable?
I am using the same view model/composable pair for a creation form and an edit form. In the creation form, the text input starts as empty, but in the edit form, the initial text input comes from the ...
3
votes
1
answer
119
views
Why does gathering the app list from PackageManager & tapping any one cause the UI to freeze?
I'm developing an Android app that gathers a list of currently installed apps, both system & user-installed, and displays them on screen via LazyColumn using a Card composable. And when the user ...
0
votes
0
answers
65
views
How to use a Navigation 3 NavEntry-scoped ViewModel inside a Fragment
I'm migrating my app to the new Navigation 3 library.
Some of my screens are still partially implemented using Fragments. In these Fragments, I want to use a NavEntry-scoped ViewModel, so that the ...
0
votes
1
answer
106
views
Using RoomDatabase in Multiple View Models
I have a database class/view model that I'd like to use in other view models to manage data locally. I was able to implement a Room Database with one view model, but I have multiple different data ...
3
votes
1
answer
277
views
Passing arguments to a Hilt view model in Navigation 3
I'm trying out the new Navigation 3 library for Jetpack Compose, and I'm a little stuck with how to pass parameters to Hilt view models. In Navigation 2, I could just pass route arguments straight to ...
0
votes
1
answer
60
views
How do I retrieve a single item from Room Database in my ViewModel?
I can't figure how to retrieve a single item from my database using it's "id", here's my code:
NoteDao.kt:
@Dao
interface NoteDao {
@Query("SELECT * FROM notes ORDER BY date DESC&...
2
votes
1
answer
45
views
Retrofit2 function call fails in viewModelScope but not in lifecycleScope
I am developing an Android application for a university project that simulates a supermarket e-shop. The app interfaces with the REST API of the products database using Retrofit2 and Moshi, with the ...
3
votes
2
answers
235
views
Android Kotlin: UI State is updated but the UI stays the same
The problem is the view model state and the content showing on the screen mismatches.
I have a shared ChatViewModel in two screens. It is initialized in the navigation as such:
val userId = "...
0
votes
0
answers
29
views
Why is the Koin factory not being called when passed in as parameter to another object with get() and parametersOf()?
I have defined the following repository in a Koin module which requires a parameter:
factory<AdRepository> { params ->
DefaultAdRepository(
inputAdId = params.get(),
...
1
vote
2
answers
46
views
App crashing due to the constructor of the ViewModel threw an exception during its execution
I am developing my android app in kotlin which has a bottom navigation drawer and one fragment is contact fragment, in that fragment need the contact access and we can add that contact to emergency ...