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

What are the benefits of returning a live data of a retrofit response

In a googlesample I have seen that the Retrofit call object is returned as a LiveData instance. @GET("users/{login}") fun getUser(@Path("login") login: String): LiveData> like so. What benefits does this have over just waiting…
0
votes
1 answer

How to pass multiple objects between destination fragments when using Navigation Component and data binding?

I successfully managed to pass an object from a fragment to another when using data binding. This is my layout file:
0
votes
2 answers

Cannot create an instance of class com.example.architectureexample.NoteViewModel

every time i run my app it shows this error in the title and i have searched for the problem some said make the ViewModel constructor public and mine is public other said Either: Remove the Context context and LifecycleOwner lifecycleOwner…
0
votes
2 answers

App not starting from Start Destination of Android NavGraph on App Hot Start

I'm using Android Navigation Architecture Component with single activity, multiple destinations. I'm initializing some of the static Variables in SplashFragment which is the "startDestination" of my NavGraph. But I'm facing problem, when app goes…
0
votes
0 answers

Do not recreate fragment after screen rotation, because it is created by LiveData observer

I track my app state in ViewModel and it's livedata. E.g. clicking on button changes the state and via livedata it creates a fragment and inflates it into the view. viewModel.panel.observe(this) { panel -> if (panel != null) { val…
0
votes
1 answer

How to add data to each item in a PagedList

Let's say I am using an API to get a list of cars. This list is implemented and is working fine using a PagedList with a PageKeyedDataSource. The cars are showing up and when I scroll down, new cars are loaded and appended to the UI. Nice! Now I…
0
votes
0 answers

How to inject repository in the application class using dagger (GithubBrowserSample)?

I want to implement authentication in my application, so I want to get the current logged user in the application class, I am following GithubBrowserSample to develop my application, but I am very new to dagger injection and I am a little lost in…
0
votes
1 answer

android architecture: call dao method from activity and pass result to child activity for filtering

I am new in Android development and I need some help for resolving the following trouble. I have 2 entities: MuscleGroup and Practice; MuscleGroup can have several practices for training. In a first Activity I display all muscle groups in a…
0
votes
2 answers

Application Crash/Navigation issue with observer when clicking "back" from fragment

I have a fragment A which sends a search query to the network, and if the result is positive uses Android navigation component to navigate to fragment B, and its done using observers. After navigation to fragment B, i click on "<-" arrow on the top…
0
votes
1 answer

SafeArgs are not generating the needed actionclass

I am building a basic app. When i press a button i want to navigate to a new fragment and that fragment should have a number of items in it. According to the documentation, Gradle should generate an inner class in my MainFragmentDirections.class,…
Casper Koch
  • 133
  • 9
0
votes
1 answer

Setting an event handler in XML using android databinding

I am trying to implement a swipe feature for recyclerview. I found this tutorial for that: Swipe ⇆ Drag ⇅ Bind RecyclerView The code is available here: Code - GitHub First of all I don't understand why is there an interface SwipeHandler which is…
0
votes
1 answer

Toolbar switches to right side when navigationIcon is shown

This is my custom toolbar: toolbar_custom.xml
rafaelasguerra
  • 2,685
  • 5
  • 24
  • 56
0
votes
1 answer

Can't resolve the Context or Application while navigating from Adapter of a fragment(A) to another Fragment (B)

Am trying to navigate from one fragment (A) to another (B), but the fragment, but the first fragment (A) has a recyclerView meaning when I click on any Item I should navigate to the next one. Am using android Navigation component but I couldn't…
0
votes
1 answer

How to use CountDownTimer with ViewModel and Livedata at activity and application level?

I want to create a one activity which is having a timer. lets say for 10 minute. i want to show time in activity. on time finish i want to save data into the server. there are two use case for saving data. 1. user is on timer screen this case is…
0
votes
1 answer

How to run android instrumental test using `androidx` and `navgation architecture`?

I'm trying to write tests for an android app. Which has one Activity and two fragments (i.e FragmentOne and FragmentTwo) by clicking a button on FragmentOne it goes to the FragmentTwo. And I wrote the test for the same and I'm using androidx and…
1 2 3
99
100