I'm working on Internet based app,so i need to monitor Internet Connection. link
I used this code in on create of mainActivity to check my internet connection it works fine.
public boolean isOnline()
{
ConnectivityManager cm = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE); return
cm.getActiveNetworkInfo().isConnectedOrConnecting();
}
But i need this monitoring should be done through out application. Where should i use this ? Any AsyncTask needed?
create a BroadcastReceiver to detect change in connection status. see Eric's answer here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With