Ответ на сообщение Re: Чайник-изобретатель! вау! вау! вау! пользователя Игорь_Борисов
StateListener yourListener = new StateListener();
TelephonyManager yourmanager =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
yourmanager.listen(yourListener, PhoneStateListener.LISTEN_CALL_STATE);
class StateListener extends PhoneStateListener{
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
switch(state){
case TelephonyManager.CALL_STATE_RINGING:
//do what you want with the incoming number here:
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
case TelephonyManager.CALL_STATE_IDLE:
break;
}
};