I have an Application that has one feature that tells users when they are online/offline. But there is a case that fails completely.
I've searched all the web (searched correctly I hope) for a solution for my problem, but never really found one. The use case is the following:
Pre-conditions:
Description of the problem:
1 - I'm connected to a wireless router
2 - The router is connected to the internet
3 - For some reason the router looses connection to the internet (I'm still connected to the router but it doesn't have connection to the Internet)
Problem:
What I need:
I think what you want/need to do is to create a background service, configured to run periodically using the AlarmManager, that will check whether a reliable network resource is available (i.e. ping a server that you trust to be online all the time).
If your ping action succeeds than you are online and connected to the internet; if it fails then you're connected but not online.
There is a compromise you will have to make between accuracy (frequency of checks) and performance with respect to battery life because waking up the service and making a web request will not be easy on the battery if you do it all the time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With