Questions tagged [android-architecture-components]

A new collection of libraries that help you design robust, testable, and maintainable Android apps. Start with classes for managing your UI component lifecycle and handling data persistence.

Filter by
Sorted by
Tagged with
0 votes
1 answer
26 views

How to get appModule properties in feature modules

My project is having feature1Module and feature2Module. These 2 are included in app module build gradle file. implementation project(":feature1Module") implementation project(":...
G Anil Reddy's user avatar
0 votes
1 answer
41 views

Is this way of filtering data in ROOM database wrong?

I have a todo list app in which i utilized the ROOM database. also this app has some filtering features so the user can filter the list based on title, priority or description. I want to know if the ...
Emz's user avatar
  • 9
0 votes
1 answer
31 views

How can I correctly implement SearchView using the ROOM library?

I'm looking to implement a SearchView feature in an app that utilizes the ROOM library. During my online research, I noticed that many examples and tutorials follow a pattern similar to the one below: ...
Emz's user avatar
  • 9
0 votes
1 answer
45 views

Potential memory leaks when using searchView along with ROOM database and live data

I'm looking to implement a SearchView feature in an app that utilizes the ROOM library. During my online research, I noticed that many examples follow a pattern similar to the one below: override fun ...
Emz's user avatar
  • 9
0 votes
0 answers
552 views

Android FAB not respecting WindowInsets in edge-to-edge xml layout with Navigation Component

My goal is to have an app layout that has a fairly constant navigation UI with various content screens. So my idea was to use the android architecture navigation component and host an ...
citizen_code's user avatar
0 votes
0 answers
13 views

Exclude certain paths from deeplink matching

I have a deeplink for a screen in the form of /path/item/{itemId}(Screen A) and I'm looking to add a new screen with deeplink /path/item/all(Screen B). When I setup Screen B with latter deeplink, it ...
clavier's user avatar
1 vote
1 answer
116 views

Android Navigation Component load 2 nested Fragments into Parent Fragment

I have a Comparator Screen which is a Fragment that is splitted into 2 sub-screens. Before using Navigation Component I could easily just: private void initializeFragments() { ...
Nexussim Lements's user avatar
0 votes
0 answers
31 views

NestedScrollView allowing scrolling past content size

I'm trying to make a twitter profile UI clone with MotionLayout. I have a tablayout, viewpager, and MotionLayout. The host fragment is: <?xml version="1.0" encoding="utf-8"?&...
Idris Ocasio's user avatar
0 votes
1 answer
39 views

Why use Transformations.switchMap?

Is there any advantage in using Transformations.switchMap like this MutableLiveData<Integer> userId = ...; LiveData<User> user = Transformations.switchMap(userIdLiveData, id -> ...
diwasip777's user avatar
0 votes
1 answer
67 views

Is there any performance improvement if I use MVVM

I was checking about MVVM architecture. I am very interested to know if there is a very good performance improvement in Android app. I have gone through several blog post which are talking about the ...
Custadian's user avatar
  • 845
0 votes
1 answer
126 views

Android NavGraph android:label"sample tile" not working

I am working on adding a toolbar title in the NavGraph. I used android:label"sample tile" in the NavGraph, but its not updating the toolbar with the label. Tried using android:label in the ...
Stephen Nedumpalli's user avatar
0 votes
3 answers
319 views

How to do parallel network requests in the repository ? MVVM

I am working on an Android project and at the moment we are doing multiple network calls in a single repository, for example in the PostsRepository class there are multiple endpoints that needs to be ...
Mysterious_android's user avatar
0 votes
0 answers
79 views

How to make swipe between components?

I newbie in programming. I maked bottom bar navigation for fragments and now I wanna make swipe transition between NestedScrollViews that in component navigation. How can I make this? ----MainActivity-...
nevrozq's user avatar
  • 41
0 votes
0 answers
96 views

Android Navigation Architecture Component go back to a specific fragment with arguments

I have a stack like this A1 -> A2 -> A3 -> B1 -> B2 -> C I am using same fragment with new instance. when I am normally navigating back with popBackStack, it is working fine. And I want ...
Abhishek Tiwari's user avatar
1 vote
0 answers
163 views

Android architecture: is RemoteMediator a DataSource itself for the repository class?

I'm learning how to implement Paging (Jetpack Paging Library) and how to fetch data from both network and local database. I have followed Google codelab and learned about the RemoteMediator class, ...
JJ86's user avatar
  • 5,055
0 votes
1 answer
429 views

Android - How to correctly send an http request by CoroutineScope in a viewModel related to the lifecycle when exiting a fragment

I need to send an http request as soon as the user presses the back button and exits the fragment. I don't want to wait for a response from the server, I just need to shoot to the server. I can't do ...
kazhiu's user avatar
  • 749
3 votes
1 answer
2k views

State Holder in jetpack compose

I am learning in State in jetpack compose. I found that State holders as source of truth. So created my some data can you guys guide me if I am doing wrong here. PairViewModel.kt class PairViewModel : ...
Kotlin Learner's user avatar
1 vote
1 answer
297 views

What is the correct usage of Flow in Room?

I am using Room and I have written the Dao class as follows. Dao @Dao interface ProjectDao { @Query("SELECT * FROM project") fun getAllProjects(): Flow<List<Project>> ...
pistolcaffe's user avatar
3 votes
2 answers
2k views

Stop collecting Flow in ViewModel when app in background

Need to collect flow in ViewModel and after some data modification, the UI is updated using _batteryProfileState. Inside compose I'm collecting states like this val batteryProfile by viewModel....
Lokik Soni's user avatar
0 votes
0 answers
177 views

How to use Navigation graph for Activity?

As we all know navGraph contains fragments screen and strings(action) that connect two fragments, this navGraph can be hosted on NavHostFragment inside an activity XML. So in the same fashion can we ...
Chandra Sekhar Bala's user avatar
2 votes
0 answers
798 views

Android Jetpack Compose Architecture: why it is not advisable to pass ViewModel directly to Screen as its argument/parameter?

I am trying to undersdand Android JetNews application which is provided as the canonical best practice architecture example application. Specifically - each screen has 3 files/classes: Route / ...
TomR's user avatar
  • 2,726
2 votes
1 answer
644 views

Unit Testing the SEQUENCE of values emitted from a single livedata

I want to unit-test the sequence of a LiveData's results. I have a result LiveData which emits values when loading, success, or error. I want to test it to ensure that loading value is emitted first, ...
Amr Salah's user avatar
1 vote
1 answer
260 views

Can we exclude specific fragments from being saved in navigation component stacks?

I've been searching on this topic for a while now, without any success. Since the last update of Navigation Component 2.5.0 in combination with BottomNavigationView the nav controller retain the stack ...
Ionut J. Bejan's user avatar
0 votes
1 answer
541 views

How to have unique Field for the id in Room Android? [duplicate]

I want to achieve unique audio_id for the id. Here is my entity class data class Members( @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") val id: Int?, var title: String, ...
KamDroid's user avatar
  • 102
0 votes
1 answer
1k views

Can pass data from View to ViewModel?

Is there mistake if I pass data from View to ViewModel? For example, pass url from onPageFinished event of WebView. I am confused because all source tell that ViewModel mustn't have any link to View. ...
Viewed's user avatar
  • 1,109
8 votes
2 answers
640 views

What is right place to start a WorkManager in MVVM architecture Android?

I have a workmanager that every five hours picks up a word from the roomdb and Notification it I do not know where is the righ place to put the work manager in the MVVM architecture. Should I use in ...
Mahdi Zareei's user avatar
0 votes
1 answer
813 views

Cannot create an instance of class viewModel.NoteViewModel

I am getting this error from a while and i have tried everything to resolve this error I have seen this solution but it didn't work for me: Cannot create an instance of ViewModel Class I have tried ...
Aashu Shaikh's user avatar
1 vote
1 answer
450 views

Navigation Controller not Switching Fragments on Button Press

I'm still new to using Navigation Components, and I am struggling to get the fragments to switch when clicking on a simple button. This is fairly simple code, but I can't for the life of me get this ...
Kafka's user avatar
  • 115
1 vote
0 answers
101 views

Is it possible to disable slide animation in the toolbar?

I navigate between fragments using the Navigation component. As you can see when I press the back button it moves me to the previous fragment but the title and overflow icon is sliding from right to ...
Taha Sami's user avatar
  • 1,575
0 votes
1 answer
149 views

Can I change topLevelDestinationIds from AppBarConfiguration?

I have CountriesFragment and this fragment is launching first (start destination) I hide the back button using this code NavigationUI.setupWithNavController(materialtoolbar, navController, new ...
Taha Sami's user avatar
  • 1,575
1 vote
0 answers
507 views

Android navigation graph resets onResume

I have a single activity application that uses Android's Navigation Component to navigate between fragments. I have an issue where, if the app is backgrounded and resumed, the navigation graph returns ...
TheLoy's user avatar
  • 183
2 votes
2 answers
639 views

Navigation component - How to clear history for nested graph only?

I use navigation component with BottomNavigationView where each tab has own nested graph. The task is to organise backstack accordingly - For ex.: User go to tab 2, navigate through nested graph by 3 ...
wa1demar's user avatar
0 votes
1 answer
46 views

What architecture should I go for do that its not a bad architecture

I have a large form to show which can not be displayed on a single page. so what we did is divide it into 7 part, each part consist of 1 fragment and all those fragments are navigated using tab ...
Keshav's user avatar
  • 173
1 vote
2 answers
1k views

Correct way to pass events back from a view in Android

I've been following the UI architecture laid out in this article https://developer.android.com/jetpack/guide/ui-layer which essentially amounts to this: It works great, but there is no example given ...
Adam's user avatar
  • 2,186
0 votes
0 answers
27 views

App Crash when observing a Live Data in Jetpack Compose Composable due to memory issue [duplicate]

I have one Composable which has one Callback function which is responsible to perform some action based on value it is observing in ViewModel. The Composable looks like. @Composable fun MyComposable( ...
Satyam Gondhale's user avatar
0 votes
1 answer
843 views

Navigation component drawer button click not working

I am facing an issue with the button click of topmost link, it is not working, even though all configurations are set up the same way as others. Can anyone look and if they can find out the problem? I ...
Amir Dora.'s user avatar
  • 2,611
0 votes
2 answers
795 views

Cannot create an instance of Application ViewModel

I'm Trying to make a viewmodel scoped to my application to control logic related to showing of not showing pin in multi activity app . I've used AndroidViewModel to pass the application to it and here ...
Abdul2511's user avatar
  • 153
1 vote
1 answer
1k views

How can I back from the second fragment to the first fragment using Navigation Component?

How can I back from the second fragment to the first fragment using Navigation Component? navigation_main.xml <navigation xmlns:android="http://schemas.android.com/apk/res/android" ...
E3219's user avatar
  • 51
0 votes
1 answer
367 views

How can I send the array from the first fragment to the second fragment using Navigation Component?

FirstFragment.java public class FirstFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ...
E3219's user avatar
  • 51
0 votes
0 answers
139 views

Firestore pagination multiple queries

After reading firestore doccumentation and some article I found out this library 'android.arch.paging:runtime:1.0.0-alphal4-1' for pagination. it works good but now my problem is that i want to pass ...
freeday same's user avatar
1 vote
0 answers
80 views

Where to send message to smartwatch? ViewModel, UseCase or Repository?

Where should I place/split the following code? The ViewModel shouldn't be responsible for business logic, but I also don't know how to handle the UseCases, have two 'special' UseCases for updating ...
Stef's user avatar
  • 45
2 votes
1 answer
310 views

Can I change the access modifier of generated safe nav args?

I am using safe nav args in my application. The point is that I have an internal class that should be passed from fragment A to fragment B. Both fragments are internal as well. The generated safe args ...
Nour El-Deen Abou El-Kassem's user avatar
0 votes
1 answer
2k views

Keep ViewModel instance when navigating back with by navGraphViewModel

So I am following Google's approach where you use single activity for the whole app and multiple view models, which are scoped to your nested nav graphs or fragments. And I have a problem with this ...
MrArtyD's user avatar
  • 111
1 vote
0 answers
191 views

Single shared viewmodel for fragments in viewpager2 or nested viewmodels (one parent and one child-viewmodel pr fragment)?

I have a main fragment with a map, and below the map is a viewpager2 with several tabs/fragments. The tabs show different information depending on user location. I see 2 possible designs: One single ...
Universal_Grammar_FTW's user avatar
-1 votes
3 answers
455 views

How to improve the following Kotlin app project code?

I am really new to android app development using Kotlin. I got a coding challenge to develop an app to search for tv shows using the TV MAZE API. I learned some Kotlin basics and developed the app. I ...
geethuth's user avatar
1 vote
2 answers
236 views

Cannot go back to Main Fragment after going into SettingsFragment using ActionBar

Hope all are safe. I have a frustrating issue using the ActionBar and the Up Button within the ActionBar. I have the following fragment structure in my app: MainFragment - |- ...
JamieRhys's user avatar
  • 226
1 vote
1 answer
283 views

How to deal with heterogeneous data sources in repository pattern?

Suppose you want to implement a repository patter for handling the data of the app. Imaging you have two Data Sources: Local cache (or database) Remote service (Rest API) The service doesn't allow ...
GVillani82's user avatar
  • 17.2k
0 votes
1 answer
364 views

How To Make Destination of Android Navigation Component Inflated in Different Destinations Not Be Edited as If They Were Shared Instances?

SCENARIO: I use BottomNavigationView component on my app setup with Android Navigation Component. It's a Social Network app with Home, Feed, Challenges, Map and Profile as main destinations of the app....
John Santos's user avatar
0 votes
1 answer
402 views

Android ViewModel Observers not working until orientation change (ViewModel works, but changing to LiveData causes the problem)

I have been trying to make an app that will double and triple my values into 2 textViews, and when I used viewModel, it survived all config changes. When I changed the result type to MutableLiveData ...
Techillaa's user avatar
0 votes
0 answers
101 views

Implementation of Room queries in Android Room

As the documentation regarding these topics seems to be limited (and I was searching a lot - either wrong or the documentation is really limited), I would like to place the question here. So far I ...
Zudy's user avatar
  • 49

1
2 3 4 5
35