Determine network connectivity using technique from Professional Android 4