user2164004
user2164004

Reputation: 1

How to Know if the incoming call is rejected or get missed

I want to detect if call was Missed or it was rejected using Call State.

public void onCallStateChanged(int state, String incomingNumber) {
    super.onCallStateChanged(state, incomingNumber);

    switch (state) {
        case TelephonyManager.CALL_STATE_IDLE:
            //when Idle i.e no call   
            if(flag==2){
                Toast.makeText(context,"Missed Call", Toast.LENGTH_LONG).show();
            flag=0;
            }else{
                Toast.makeText(context, "Phone state Idle", Toast.LENGTH_LONG).show();
            }

            break;
        case TelephonyManager.CALL_STATE_OFFHOOK:
            // flag=0;
            // when Off hook i.e in call
            // Make intent and start your service here
            Toast.makeText(context, "Phone state Off hook", Toast.LENGTH_LONG).show();
            flag=1;
            break;
        case TelephonyManager.CALL_STATE_RINGING:
            //when Ringing
            Toast.makeText(context, "Phone state Ringing", Toast.LENGTH_LONG).show();
            flag=2;
            break;
        default:
            break;
    }               
}

and how can i popup Dialog box for Call_STATE_RINGING?

Upvotes: 0

Views: 1229

Answers (1)

DjHacktorReborn
DjHacktorReborn

Reputation: 2928

When you reach ideal after ringing read call logs and get type of call if missed it has a type 3 and if rejected type 5

Upvotes: 1

Related Questions