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

How to replace fragments using Navigation from Jetpack?

I'm setting up the navigation for child game and I have some problem with backstack navigation. So app contains Splash Screen, 4 pages (fragments) to collecting some Cards with game info and Main Fragment. So app flow: Splash ->First-> Second ->…
0
votes
0 answers

Interaction ViewModel and SharedViewModel according to the CleanArchitecture principles

In my app I have some data that will be used across all app in the different fragments. According to the Official Android Guides we should use LiveData and SharedViewModel That documentations shows just how to use data from SharedViewModel in…
0
votes
2 answers

How can I create view model per fragment inside viewpage

Basically I want to create view model per fragment in view pager. each page in the view pager has different data to fetch from network. View pager -> view pager adapter -> fragment with view model Since all of these fragment using same view model,…
0
votes
1 answer

Combine Room and Content Resolver data into one object

My app supports adding contacts to a note. In this process, I'm storing a Contact entity in my apps database, where I primarily use the contactId to identify the contact. In my UI, the name should be displayed, too. Therefore, I'm looking for a…
0
votes
3 answers

Two-way DataBinding went wrong after device rotation

I use Android DataBinding Library (Two-way) with LiveData (binding syntax @={}) To reuse UI, I intensively use include layout mechanism when designing layout file. Actually, I include a same layout file multiple times in building a form…
0
votes
0 answers

When I need to pass data in between fragments or observe liveData in each fragment?

I have data that I am fetching at the beginning of the application and then I need to use that settingsLiveData through whole application. I am thinking about 2 solutions 1.Create SettingsViewModel and I can have instance of this viewModel in each…
I.S
  • 1,904
  • 2
  • 25
  • 48
0
votes
0 answers

How to remove the logic from ViewModel and move to Repository

I have this piece of code which is checking if it is close to the start time and if no repeats until it is started I want to have less logic in ViewModel how can I refactor this piece of code? uiScope.launch { when (val unixTimeMillisecond…
0
votes
1 answer

What would be the SQL query for my problem?

I need help with a SQL query for room within an android app. There is a table questions. This table has 3 columns: id question id_sub_cateory Furthermore there is table_sub_categories with folloing columns: id sub_category id_category And…
Peter
  • 579
  • 2
  • 7
  • 18
0
votes
1 answer

How to receive the notification action using WorkManager

Before the introduction of WorkManager, I was using an IntentService for my notification actions. So If I had several actions, I would simply pass those actions in the intent and then receive them like this in my IntentService class. …
0
votes
0 answers

Best practices for single activity app and view models

I just started programming for android and, as soon as my application started growing, I began to ask myself questions about best practices. I have a single activity application with a Room database. I have the following views: list of…
0
votes
1 answer

ERROR: Failed to resolve: androidx.room:room-runtime:1.0.0

I am learning android mvvm tutorial but I am getting following errors from gradle ERROR: Failed to resolve: androidx.room:room-runtime:1.0.0 Show in Project Structure dialog Affected Modules: app ERROR: Failed to resolve:…
0
votes
1 answer

Room Database Migration with Indexed Entity

I have 'ImagePendingDBStore' entity, I have added 4 more columns in this entity (see comment in code below). In this, one column is indexed 'referenceId' @Entity(tableName = "ImagePendingDBStore",indices = {@Index(value = "referenceId")}) public…
0
votes
1 answer

How to use an existing database with an Android application using room ORM with Kotlin

My project has some initializes data so I have already create a sqlite database with navicat application. I use kotlin instead of java and use room ORM too (android-architecture-components). how can i copy my database too my project from asset…
0
votes
2 answers

Shared viewModel achived fragment lifecycle

How I can use shared viewModel with fragments without activity? Like in code but in place of requireActivity() use ParentFragment. In this case when ParentFragment will destroyed, SharedViewModel is cleared, but when I provide SharedViewModel from…
0
votes
4 answers

How to go back with WebView inside Fragment controlled by NavHostFragment?

Current situation: There is only one activity called MainActivity. MainActivity maintains the NavHostFragment. There is a WebViewFragment which embeded a WebView inside. Thera are many other fragment controlled by NavHostFragment. What troubles…
1 2 3
99
100