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.

Architecture Components compromises of below components:

Handling lifecycles Create a UI that automatically responds to lifecycle events.

LiveData Build data objects that notify views when the underlying database changes.

ViewModel Store UI related data that isn't destroyed on app rotations.

Room Access your data with the power of SQLite and safety of in-app objects.

Data binding Useful to bind data directly through layouts xml file, so no findViewById()anymore.

Navigation Handles navigating between your app's destinations.

1709 questions
0
votes
3 answers

why I can't change toolbar title after using back button (physical back button) in Android?

here is the project to be downloaded: https://www.dropbox.com/s/lq3p2pnwjacik7s/testApp.zip?dl=0 I am using Android navigation component, and here is the screenshot of the app: as you can see, in the MainActivity layout, there are a…
0
votes
1 answer

why my progress bar from my activity doesn't show in my fragment after I press hardware back button?

so I am using navigation controller component in Android. I have a progress bar in my MainActivity that will be used in all my fragments when the user need to wait while fetching data from server. in my onCreate MainActivity it will be declared like…
0
votes
1 answer

Is there a way to set up a kafka server on Android?

My goal is to feed a NN on Android with real time streaming events from various data sources (sensors, other servers). I have created a working set up on a linux server with Kafka to explore the concept. Replicating this set up to an Android device…
0
votes
2 answers

Is it necessary to use fragment in the activity?

Recently learning android-architecture-samples, I found that each activity uses fragment, even if the activity doesn't really need fragments, in my opinion, this makes the activity lazy and leads to a lot of files. For example, TaskDetailActivity…
0
votes
1 answer

How can I run a service the would have access to my database and could run operations on it, but won't stuff up the UI thread

I am building an app the needs to go through a collection of photos stored locally, which I import to a room database, and try to detect for each if it contains faces or not. I've got everything sorted, my only issue is how to run this operation,…
0
votes
1 answer

LiveData unit test do not pass under coroutine and multithread because of return true instead of expected false

EnrollmentViewModelTest @Test fun getUserProfile() { val responseSnapshot = this.javaClass.getResource("/userDetailResponse.json").readText() val user = Gson().fromJson(responseSnapshot, User::class.java) val response =…
0
votes
1 answer

LiveData update after changing from inactive to active

If I understand it correctly when there is no active observer for a LiveData object, it doesn’t get changes of the source anymore, for example, it doesn’t require to get changes from SQLite (LiveData in Dao). If again one of its observers becomes…
0
votes
0 answers

Problem with navigation what if i have multiple Bottom NavViews

Hello I am having a lot of problems with the implementation of this. i have the following xml at main activity content_main...
0
votes
1 answer

I want to display Toast message on Retrofit failure in ViewModel Class

Hi I have this App where it displays movies from TMDB I am having an issue where I can't display a feedback to users that may lead them to keep unnecessarily waiting When my app starts without internet or server returns no data public…
0
votes
1 answer

Room nested query and subquery

I use Room in my Android project and want to write a complex query. I search about it and there is some answers witch says use @Embedded like this: class TripAndListsAndListItems { @Embedded var trip: Trip? = null …
0
votes
1 answer

Observe not called with LiveData

I'm using the PagedList architectural components using a Room database and I am having trouble returning results to the observe method. Here is my Dao: @Dao interface WorkPackageStorageDao { @Query("SELECT * from workpackages where id =…
0
votes
0 answers

How to know from what fragment I'm returning when using Navigation Component?

I have four fragments already set up in my app using Navigation Components: I can go from MainFragment to MoviesFragment or TrailersFragment as well as from the UserFragment to one of them. From the MainFragment I can simply navigate to the…
0
votes
1 answer

Undo setup done using NavigationUI

I have setup drawer using NavigationUI NavigationUI.setupActionBarWithNavController(this, navController, drawerLayout) NavigationUI.setupWithNavController(navView, navController) How can i remove/un-link the drawerLayout and toolbar from…
0
votes
1 answer

Why is DataBinding View Visibility not working

I have the following DataBinding setup, but whenever "isPrivate" is true, the visibility stays View.GONE layout.xml
0
votes
0 answers

how to preserve properties value in the fragment after switching tab in bottom navigation view?

I have 4 tabs in the bottom navigation view called : Home Search Favourite Profile here is the simplified code of my profile fragment class ProfileFragment : Fragment() { private var lastDocumentFromQuery : DocumentSnapshot? = null …