1.

What is WorkManager? How it is useful in the application?

Answer»

By USING LiveData, we can Observe activity lifecycle METHOD, so livedata will not trigger the change method if view is destroyed. There are many advantages of LiveData

  • Since livedata is present inside View Model it's retained on configuration change
  • Activity View is observing to live data
  • There is no memory leak as View Model doesn’t have any REFERENCE of activity
  • Observers have their own lifecycle so they are AUTOMATICALLY cleaned when their Lifecycle is destroyed
  • When your activity goes into any state other than STARTED or RESUMED it will not call the onChanged method on the observer.
  • ViewModel exposes livedata that view observes it. Whenever livedata changes view gets notified and it could re-render itself.


Discussion

No Comment Found

Related InterviewSolutions