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.