Can anyone give a simple example of the usage of PhoneStateListener?

I have tried to overwrite the listener and register it with the
TelephonyManager with the Context.TELEPHONY_SERVICE.

But i only saw my logging statement printed out right when I started
to run the application.  The logging showed the PhoneState as IDLE.
But then after that when I use telnet to emulate an incoming call, I
don't see the logging statement been printed for PhoneState - RINGING
or PhoneState - OFFHOOK.

here is my code snippet:
TelephonyManager tm =
(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(this, CallStateListener.LISTEN_CALL_STATE);

public void onCallStateChanged(int state, String incomingNumber)
{
    switch(state)
    {
          case TelephonyManager.CALL_STATE_DLE:
               Log.d(DEBUG, "PHONE STATE - IDLE");
               break;
          case TelephonyManager.CALL_STATE_OFFHOOK:
               Log.d(DEBUG, "PHONE STATE - OFFHOOK");
               break;
          case TelephonyManager.CALL_STATE_RINGING:
               Log.d(DEBUG, "PHONE STATE - RINGING");
               break;
     }
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to