Skip to main content
Filter by
Sorted by
Tagged with
81 votes
5 answers
67k views

I have a fragment: class MyFragment : BaseFragment() { // my StudentsViewModel instance lateinit var viewModel: StudentsViewModel override fun onCreateView(...){ ... } ...
0 votes
1 answer
84 views

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
0 answers
47 views

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 ...
2 votes
1 answer
149 views

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 ...
7 votes
5 answers
5k views

I am confused what to use, whether to use update or copy for changing/updating the state of UI in Jetpack Compose. Some say to use _uiState.update { it.copy() } Some say to use _uiState.value = ...
3 votes
2 answers
102 views

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
128 views

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
1 answer
109 views

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 ...
0 votes
1 answer
68 views

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
47 views

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 ...
0 votes
0 answers
37 views

I have defined the following repository in a Koin module which requires a parameter: factory<AdRepository> { params -> DefaultAdRepository( inputAdId = params.get(), ...
1 vote
1 answer
501 views

For the moment I use this approach in my ViewModel: private val _email = MutableStateFlow("") val email: StateFlow<String> = _email.asStateFlow() fun updateEmail(email: String) { ...
2 votes
1 answer
115 views

I'm currently learning Android app development, and doing the Architecture Components course. In the codelab regarding ViewModel and State in Compose, I'm unsure why they do things the way they do. I'...
3 votes
4 answers
3k views

I'm currently facing the following problem and hope someone might be able to help: I have a flow in my ViewModel that provides me with some data. Now I would like this data to be reloaded on pull-to-...
7 votes
2 answers
6k views

My app uses hilt and I have some work with LoadManager inside my activity that read contacts using ContentResolver and when I finish work I get the cursor that I send to my viewModel in order to ...
0 votes
0 answers
56 views

So, I am new to Android development and no-one else seems to have this problem, so I guess I am doing something fundamentally wrong... I have a table in a Room DB where I want to store metadata of ...
264 votes
5 answers
99k views

With the introduction of the Android Architecture Components library, several new classes were introduced, including AndroidViewModel and ViewModel. However, I'm having trouble figuring out the ...
3 votes
2 answers
2k views

I want to update my old android project and want to use the recommended way of Google with ViewModel and Livedata. I use Viewpager2 and Tablayout with 4 fragments in it. The first fragment has a ...
0 votes
1 answer
52 views

If you have code in your ViewModel that needs to check a viewModel's stateFlow and also needs to update it, and you want to extract this code into a separate class because it is already too much code, ...
1 vote
1 answer
116 views

I am implementing a weather app using Jetpack Compose. It includes a function to choose the temperature unit (Celsius or Fahrenheit). Whenever the temperature unit is changed, the data should refresh. ...
2 votes
2 answers
231 views

I have created a compose project that follows the standard architecture sttucture of a project. It has a data class, interface, api class, repository. The repository is connected to a viewmodel and ...
2 votes
1 answer
417 views

I encountered the following compile-time error while using Hilt and Ksp for dependency injection: Cannot find symbol import xyz.linglitel.lmusic.viewmodel....
0 votes
0 answers
36 views

I have a Fragment that contains several CheckBoxes: class TestFragment : Fragment() { private lateinit var checkBox2er: CheckBox private lateinit var checkBox3er: CheckBox // ... ...
5 votes
3 answers
3k views

There is a screen level composable under an activity. When user is navigated to that screen, I'm using a LaunchedEffect(Unit) {} to call view-model function which does some work. Now, this works fine ...
0 votes
0 answers
116 views

I am using Jetpack Compose with a NavHost and NavHostController to handle navigation. I have a dialog that appears when a button is clicked. This dialog includes a button that navigates to another ...

1
2 3 4 5
38