Home > DeveloperSection > Forums > How can I monitor for changes to mobile data being enabled on Android?
naomi burke
naomi burke

Total Post:28

Points:196
Posted on    November-10-2015 3:52 AM

 Android Android 
Ratings:


 1 Reply(s)
 409  View(s)
Rate this:
How can I monitor for changes to mobile data being enabled on Android?


Mayank Tripathi
Mayank Tripathi

Total Post:397

Points:3117
Supported
Posted on    November-10-2015 3:55 AM

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
}

Don't want to miss updates? Please click the below button!

Follow MindStick