Hello,
Here is my code for Phone State Listener the phone call state changed
should be called first when state = RINGING and after that state =
OFFHOOK and after that when call is ended then state = IDLE but so
according to this function i should get three toast but  i am getting
different number of toast each time :::
Can anyone here knows how should i resolve this problem .

///CODE ::
public class MyPhoneStateListener extends PhoneStateListener{
        Context context;
        MyPhoneStateListener(Context context){
                this.context = context;
        }


        Date dt;

        long seconds1;
        public void onCallStateChanged(int state,String incomingNumber){
                  switch(state){
                  case TelephonyManager.CALL_STATE_OFFHOOK:
                                        dt = new Date();
                        seconds1 = dt.getSeconds();

                        Toast.makeText(this.context, "OFF
HOOK"+String.valueOf(seconds1), Toast.LENGTH_SHORT).show();
                        break;
                        case TelephonyManager.CALL_STATE_RINGING:
                                ///
                                dt = new Date();
                seconds1 = dt.getSeconds();
                                ///
                                Toast.makeText(this.context, 
"RING"+String.valueOf(seconds1),
Toast.LENGTH_SHORT).show();
                                break;
                        case TelephonyManager.CALL_STATE_IDLE:
                                dt = new Date();
                                seconds1 = dt.getSeconds();
                                Toast.makeText(this.context, 
"IDLE"+String.valueOf(seconds1),
Toast.LENGTH_SHORT).show();
                                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