i am working on an tracking app where i needs to capture mobile data enable/disable event. i am successfully able to get internet enable/disable broadcast by the following code:
private BroadcastReceiver networkInfoReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
ConnectivityManager connect = (ConnectivityManager) getSystemService(getBaseContext().CONNECTIVITY_SERVICE);
NetworkInfo network = connect.getActiveNetworkInfo();
if (network == null || !network.isConnected()) {
sharedPreferencesEditor.putBoolean(Constants.INTERNET_STATUS,false);
} else {
sharedPreferencesEditor.putBoolean(Constants.INTERNET_STATUS,true);
}
sharedPreferencesEditor.commit();
}
but by using this code snippet i got only internet status. it will be fire in both conditions whether data disable or no network Area. but i needs a broadcast which fires only when mobile data disable manually.