Check internet connectivity in MVVM

129 Views Asked by At

I have a app where I am using retrofit and mvvm pattern to fetch the data from api , I also use the room database to save those data locally . This app requires internet connection. But when I didn't provide the internet connection the app is crashing. I want to know that how to implement the internet connection check ,which will show a diolog to the user to provide the internet connection without crashing the app and where to write this functionality while using mvvm. Like on the viewmodel or mainActivity or in the fragments, because I have multiple fragments and the first user screen is also the fragment.

Please help me to resolve this , for any help thanks in advance.

0

There are 0 best solutions below