π·οΈ In android projects it is common to communicate with a network and get data from a remote server or post data into remote server.
π·οΈ There is a common case to check connectivity before performing either of the case.
π·οΈ Sometims when the connectivity fails and gets connected, again we need to show a notification just like how youtube does.
π·ππ π π ππππ ππ πππππππππ ππ ππππππ’ ππππππππ
π‘
π·οΈ Everytime we used to call a API, we check connectivity and say if we have multiple API's, we do the same check multiple times.
π·οΈ And to monitor the connectivity change we used to listen to broadcast from the android system
π·οΈ With the introduction of live data and the life-cycle observers, we can have a better implementation to monitor and react to the network changes.
π·οΈ We can store the changes in a variable and just use that to determine the state of the network instead of checking network everytime.
π·οΈ By this way is efficient and less error prone and the is single source of truth for current connectivity state.
If you feel like support me a coffee for my efforts, I would greatly appreciate it.
Read contribution guidelines for more information regarding contribution.
Feature requests are always welcome, File an issue here.
Support it by clicking the β button on the upper right of this page. βοΈ
This project is licensed under the Apache License 2.0 - see the LICENSE file for details