With this code using in your app you can actually check whether the user is connected to internet or not
Read this post on testedcodes.net