Questions tagged [android-architecture-lifecycle]

68 questions
1
vote
1 answer

Duplicate files copied in APK META-INF/android.arch.lifecycle_runtime.version

I have the following error while building my APK. Duplicate files copied in APK META-INF/android.arch.lifecycle_runtime.version File1: /Users/.../build/intermediates/exploded-aar/com.google.android.gms/play-services-base/12.0.0/jars/classes.jar …
B.B.
  • 924
  • 2
  • 11
  • 28
1
vote
1 answer

Should I share my ViewModel across two fragments?

I'm attempting to follow Android best practices and use the latest recommended architecture components. You can see my attempt so far here: https://github.com/randroid88/TodayILearned Right now the app's features are very limited. It has a Room db…
1
vote
0 answers

Android ViewModel Sharing Between Fragments

My team is just beginning to transition our app over to using ViewModels in Android and need some assistance. Our app has a collection of buildings displayed in a fragment. You can select a building in the list to view details about that building in…
1
vote
2 answers

Android Architecture components : Get Activity methods when using LifecycleOwner

While implementing Architecture components I am facing this issue import android.arch.lifecycle.Lifecycle import android.arch.lifecycle.LifecycleOwner import android.os.Bundle import com.reversebits.trendyvidz.R class MainActivity : LifecycleOwner…
1
vote
1 answer

Can lifecycle events be observed without annotation processing in the new Android Lifecycle Architecture component?

annotation processing/code generation adds significant overhead to build times and breaks incremental builds. Can I (reactively, aka not by manually forwarding events) get a fine-grained callback for Lifecycle.Event.ON_STOP using the Android…
1
vote
3 answers

Implementing the new Android Architecture Components with Activity and Fragments

Currently I try implementing an application with the architecture components provided by android. In terms of only using activities in the UI Package there is no problem with that, but if I implement several fragments which are held by one activity…
1
vote
1 answer

Android LiveData: MutableData is never on active state

I have the following ViewModel: class SignInViewModel @Inject constructor(val api: BillingApi) : ViewModel() { val googleApiClient: MutableLiveData = MutableLiveData() } On my Activity.onCreate(onSavedInstanceState: Bundle?) I…
Olinasc
  • 1,261
  • 1
  • 12
  • 20
1
vote
1 answer

Holding reference of Lifecycle object in LifecycleObserver

In the LifecycleObserver class how good is it a practice to hold the reference of Lifecycle object? What complication can arise? class MyLocationListener implements LifecycleObserver { private Lifecycle mLifecycle; public…
1
vote
4 answers

When does a LifecycleRegistry instance start listening to LifecycleOwner's lifecycle changes?

I've started learning architecture components, but can't find one thing. LifecycleFragment just creates a new LifecycleRegistry object, which does not start observing the fragment's lifecycle. I guess the LifecycleRegistry object starts listening to…
0
votes
1 answer

Get Activity Context from Lifecycle object

I have made my component Lifecycle-aware. I want to use activityContext in that component. My question is: is there any way to use activityContext from the Lifecycle object?
0
votes
0 answers

OnChanged of MediatorLiveData not called if Transformatons not used

I am following https://github.com/android/architecture-components-samples/tree/88747993139224a4bb6dbe985adf652d557de621/GithubBrowserSample for sample application. I can see that they have used NetworkBoundResource class to handle db operations and…
0
votes
1 answer

android.arch.lifecycle:extensions:1.1.1 directory

I am trying to add lifecycle:extensions to my project but it shows the err Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve android.arch.lifecycle:extensions:1.1.1. None of solutions provided in the web doesn't…
0
votes
2 answers

LifeCycle Aware Codelab Concept

I was learning the Lifecycle Aware Components from the Codelab which starts from Chronometer example. In step 2 I have a doubt. These are the code files for reference ChronoActivity2.java package com.example.android.lifecycles.step2; import…
0
votes
0 answers

Android Java ViewModel with Dagger 2

I'm trying to use viewmodel with dagger 2. However, on orientation change, ViewModel is being recreated. I get SwipeRefreshLayout NullPointerException on featuredViewModel.getLoading.observe(). Where is my fail? Dagger 2 Fragment Module…
user3710623
0
votes
1 answer

Attempt to invoke virtual method 'boolean androidx.work.State.isFinished()' on a null object reference

I am trying to learn WorkManager for Android using codeLab documentation. I app crash when I try to test functionality of beginUniqueWork(Ensure Unique Work) I just implement beginUniqueWork and test app with selecting image multiple time. Code I…