Questions tagged [lifecycleowner]

22 questions
0
votes
1 answer

View binding in traditional way using findViewbyId in LifecyclerObserver

I am new to the lifecycle observer (fragment). I am trying to link the views defined in XML with fragment. traditionally, we use to do it in onActivityCreated method using findViewById. How can we do it while using lifecycle observer? Kindly do not…
0
votes
0 answers

Can ViewModel implement LifecycleOwner?

I know that, ViewModels should never keep a reference to a LifecycleOwner since it keeps a reference to a context and hence this causes a memory leak. But my question is, can I implement a LifecyclerOwner for ViewModel itself? with two valid…
Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
0
votes
1 answer

Pass activity to LifecycleObserver

I need to pass activity to a LifecycleObserver class for a location task: class LocationObserver( private val context: Context, private val activity: FragmentActivity) : LifecycleObserver { private var locationClient:…
0
votes
0 answers

ViewModelProvider nested fragment can't receive data

Below is the structure of my app MainActivity |-- HomeFragment | |-- ViewPager | |-- FirstViewFragement | |-- SecondViewFragementme | |-- ThirdViewFragement |-- SettingFragment |-- OtherFragment The app flow is displayed below…
B L Λ C K
  • 600
  • 1
  • 8
  • 24
0
votes
0 answers

Android Workmanager

I'm having trouble figuring out how to use Android's Workmanager. Essentially, I want to make a OneTime request with a time delay, determine success, then do some stuff. The Worker class does NOTHING. What I'm expecting is a SUCCESS code to be…
RudyF
  • 805
  • 1
  • 10
  • 16
0
votes
0 answers

LifecycleObserver doesn't call onPause event on custom View - Android

I am trying to implement LifecycleObserver on a custom RelativeLayout View. I am able to get the ON_RESUME event but for some reason the ON_PAUSE or ON_DESTROY event doesn't get triggered. public class MyView extends RelativeLayout implements…
0
votes
1 answer

Android - Under what circumstance / use case I would want to implement a custom LifecycleOwner

https://developer.android.com/topic/libraries/architecture/lifecycle#implementing-lco The docs say that Fragments and Activities in Support Library 26.1.0 and later already implement the LifecycleOwner interface. This is greatly useful if we can use…
Goran Horia Mihail
  • 3,536
  • 2
  • 29
  • 40
1
2