I am creating the application that using
<uses-permission android:name="android.permission.INTERNET" />
And I am using WebView to launch URL. But when mobile didn’t connected to WIFI and Internet 3G, in WebView appear exactly URL link.
I don’t want user can see the URL link in WebView if no internet connection, how can i do it?
Best Regards,
Virak
Check the return of the following function (true for online, false for not) and modify the output depending on what you’re after.
If what you want is to show a popup or a toast if there is no connectivity, then having that function in your activity will allow you to do the following, which will show the Toast.
I like using the function I’m giving you (have no idea where I copied it from, months ago) because it allows me to easily modify it if I need it to only return true if I have wifi or mobile internet, allowing me for instance to download a high definition video only if the wifi connection is available.