Issue
Lifecycle-aware components perform actions in response to a change in the lifecycle status of another component, such as activities and fragments. These components help you produce better-organized, and often lighter-weight code, that is easier to maintain.
What is the use of this in real application. Give the example or live scenarios.
What is the Use of LifecycleObserver?
Solution
Switching between coarse and fine-grained location updates. Use lifecycle-aware components to enable fine-grained location updates while your location app is visible and switch to coarse-grained updates when the app is in the background.
LiveData, a lifecycle-aware component, allows your app to automatically update the UI when your use changes locations.
Stopping and starting video buffering. Use lifecycle-aware components to start video buffering as soon as possible, but defer playback until app is fully started. You can also use lifecycle-aware components to terminate buffering when your app is destroyed.
Starting and stopping network connectivity. Use lifecycle-aware components to enable live updating (streaming) of network data while an app is in the foreground and also to automatically pause when the app goes into the background.
Pausing and resuming animated drawables. Use lifecycle-aware components to handle pausing animated drawables when while app is in the background and resume drawables after the app is in the foreground
refer this link
https://developer.android.com/topic/libraries/architecture/lifecycle.html
some examples
https://github.com/shashankkapsime/android-location-services-using-livedata-lifecycle-components
https://github.com/nikkijuk/LifecycleAwareRssReader
Answered By - MarGin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.