Beware of a such code. Anybody with a slow connection will fail, a 1s timeout is not enough. And lock your mainthread, so it must happen in another thread, or use UrlRequest.
Emil approach is more safe: using the Connectiviy manager on android would be the first thing to do.
Then, just handle any error in your workflow on network and in case of an error, analyse it and correctly redirect the user on a good error message.
Checking internet at the start / before doing things doesn't mean you'll be free of error after, so conceptually, the approach is not helping.
Either ask internet connectivy to show an online/offline mode. If the connectivity is available, then do the usual work.