Hi guys, I have a problem when connecting

Hi guys, I have a problem when connecting.
For example, when the internet is disconnected, the app automatically exits and that’s easy over the network. The problem here is that even if the network (phone / wifi) is connected, but it is not working (no internet) or the internet is weak, nothing happens and the app does not exit.
Is there a solution to exit the application when the Internet is connected but not working or weak?

I think, if network is connected and imagine you want to send data to gsheet… while blocks ate getting ready to send data to gsheet meanwhile set clock to timer for particular second say 5sec. Before the timer if you get response from gsheet then network is strong if not alert the user that network is week and again timer to 5morw sec… in this period also no successful action taken then imagine it is false attempt and alert the user , network is weak so unable to process your request. Also save the attempt in firebase under a tag of false request. Later you can delete such common attempt between firebase value and gsheet , suppose after 10sec if anything posted.

Understand, anything?? Other people may have some other view. So stay tune