How can I monitor for changes to mobile data being enabled on Android?

Total Post:28

Points:196
 882  View(s)
Ratings:
Rate this:
How can I monitor for changes to mobile data being enabled on Android?
  1. Post:397

    Points:3117
    Re: How can I monitor for changes to mobile data being enabled on Android?

    You can use OnNetworkActiveListener to monitor activation of network data. The ConnectivityManager class can give you infos on the currently active network connection. It would go like this :

    ConnectivityManager cm = getSystemService(Activity.CONNECTIVITY_SERVICE);
    NetworkInfos networkInfos = cm.getActiveNetworkInfo();
    if(networkInfos.isConnected()){
        //Do something
    } else {
        //Do something else
    }

Answer