mPhone = (TelephonyManager) this
.getSystemService(Context.TELEPHONY_SERVICE);
mPhone.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
| PhoneStateListener.LISTEN_DATA_ACTIVITY);
mPhoneStateListener = new PhoneStateListener() {
@Override
public void onDataActivity(int direction) {
super.onDataActivity(direction);
Log.v("kevin", "onDataActivity: " + direction);
}
@Override
public void onDataConnectionStateChanged(int state) {
super.onDataConnectionStateChanged(state);
if(state == TelephonyManager.DATA_DISCONNECTED){
Log.v("kevin", "onDataConnectionStateChanged: " + state);
}
}
@Override
public void onServiceStateChanged(ServiceState serviceState) {
super.onServiceStateChanged(serviceState);
Log.v("kevin", "onServiceStateChanged");
}
};