Questions tagged [android-architecture]
64 questions
98
votes
4 answers
What is difference between MediatorLiveData and MutableLiveData in MVVM
I have searched a lot but not found the crystal clear answer for the questions:
What is the difference between MediatorLiveData and MutableLiveData?
What are the suitable condition to use either of them.

Lalit Kushwah
- 3,861
- 5
- 25
- 40
89
votes
6 answers
BoundService + LiveData + ViewModel best practice in new Android recommended architecture
I been struggling a lot thinking about where to place Android Services in the new Android recommended Architecture. I came up with many possible solutions, but I cannot make up my mind about which one is the best approach.
I did a lot of research,…

dglozano
- 6,369
- 2
- 19
- 38
54
votes
9 answers
A dependent feature was defined but no package ID was set. You are probably missing a feature dependency in the base feature
I am following one of the Google Codelabs for making an Instant App.
And I was trying to create topeka-ui (A UI feature module for Instant Apps).
When I try to run one of the instant app module it says :
A dependent feature was defined but no…

erluxman
- 18,155
- 20
- 92
- 126
14
votes
6 answers
Androidx and databinding
I'm migrating my dependencies for an Android P test to the androidx dependencies. For some not very clear reasons my project does not compile anymore (and no I won't provide the details to avoid a distinct problem). I found out (via gradlew…

rekire
- 47,260
- 30
- 167
- 264
11
votes
1 answer
How to share dependencies in a Modularized Android App
I have an Android project which is architectured in a Modularized way. I have modularized the projects by dividing their source code between multiple Gradle modules, following the clean Architecture.
Here is the structure of the App.
The top…

doe
- 971
- 2
- 11
- 27
8
votes
1 answer
Best practice for using Shared Preferences in MVVM Android?
I've been searching for the best approach to using Shared Preferences in MVVM architecture in Android but I could just find pieces and thus having no clear image over ho to do it in the best way. Therefore I have a few questions:
Should I keep a…

radus14
- 140
- 2
- 8
8
votes
1 answer
Passing data from one viewmodel to another android MVVM
I have a design-related question for you guys.
So, I have been following Guide to App Architecture by Google to build my application using Kotlin, MVVM and data binding. I am using Jetpack components(navigation, livedata etc) as prescribed by…

hushed_voice
- 3,161
- 3
- 34
- 66
7
votes
0 answers
How to add swipe left or right in Tabs of tab layout when implemented using Navigation Architecture component
One way to implement swipe in Tabs of TabLayout is using viewpager. Using navigation architecture component for navigation it is not clear how to use viewpager. If we are not using viewpager, what is the recommended way to implement swipe left or…

explorer2050
- 191
- 7
6
votes
2 answers
Does event wrapper pattern replace the use of SingleLiveEvent?
I'm adopting MVVM to my Android apps recently. In order to solve the problems underlying with the lifecycle of an app, Google had released LiveData.
The usage of LiveData has different scenarios, as pointed out in the medium article wrote by Jose…

Carter Chen
- 792
- 1
- 8
- 22
6
votes
2 answers
Inter communication between android viewmodels
I have a customer detail page which load's a customer detail from "customer" table and allow some editing to some details, one which is customer's location. The customer's location is a spinner which drop down item is loaded from "location"…

user3109848
- 163
- 1
- 8
5
votes
2 answers
Implementing MVP on a single activity with two (or multiple) fragments
I'm developing a small application that shows a list, and when an item is clicked it opens a secondary screen with the item details. I want to implement MVP as my architecture for this app, and i have been struggling figuring out how to do that when…

mgR
- 195
- 1
- 4
- 11
4
votes
1 answer
Is it ok for view to ask for data from ViewModel in MVVM?
I have been reading about MVVM pattern. View is supposed to observe for changes in ViewModel and act on it accordingly but I am confused if following code in View is ok in MVVM architecture.
fun onClick(view:View){
…

M-Wajeeh
- 17,204
- 10
- 66
- 103
4
votes
2 answers
Android Lifecycle ViewModel not persisted after locking and unlocking in landscape mode
I have a pretty simple app with a dummy Activity and dummy Android Lifecycle ViewModel ViewModel.
FragmentActivity
class FragmentActivity: AppCompatActivity() {
companion object {
private const val TAG = "FragmentActivity"
…

dkarmazi
- 3,199
- 1
- 13
- 25
4
votes
2 answers
What dependencies should one be putting in each module of an instant app?
I'm in the process of writing an instant app for others to learn how to write an instant app and hoping to get some ideas on how to best structure the app for dependencies.
Now reading the Android developer docs on project structure and referencing…

Andrew Steinmetz
- 1,010
- 8
- 16
3
votes
1 answer
Update part of UI using MVI on Android
One thing I have understood about MVI, is that the model creates the state and the view handles it. The view ALWAYS gets a FULL state from the model, meaning that every state given to the view includes information for every part of the view, every…

jpgw
- 109
- 8