Need help on phone CALL ACCCEPT!

Put your problem here if it does not fit any of the other categories.

Need help on phone CALL ACCCEPT!

Postby xiaozhe » Wed May 06, 2009 12:17 pm

I am working on such an application on Android Phone.

The original UI of incoming call is to be replaced by my own UI, say it MyIncomingCallUIActivity.

The following is my design:

1. implement an service, in which "PhoneStateListener" is used to listen the call state, when the
CALL_STATE_RINGING state is captured, an intent is send out to start the MyIncomingCallUIActivity
activity after 500ms delay. The delay is for the MyIncomingCallUIActivity to show on the screen of
the native incoming call UI.




PhoneStateListener listener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
if (mState == TelephonyManager.CALL_STATE_IDLE) {
Intent intent = new Intent(this,
MyIncomingCallUIActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
Thread.sleep(500);
} catch (Exception e) {

}
startActivity(intent);
}
break;
case TelephonyManager.CALL_STATE_IDLE:
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
default:
break;
}
}
};


However, how to accept the incoming call?
when using the following code in the MyIncomingCallUIActivity, if "call " key is pressed, the native
incoming call window shows, user has to press the "call" key again to accept the call. But in the design,
the original native incoming call window should not show, and the "call" key press should lead to the
accept of phone call.

Plumsminus, snow and all others, Please help!

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_ENDCALL:
case KeyEvent.KEYCODE_CALL:
finish();
return super.dispatchKeyEvent(event);

case KeyEvent.KEYCODE_BACK:
return true;
default:
break;
}
return super.dispatchKeyEvent(event);
}
xiaozhe
Freshman
Freshman
 
Posts: 2
Joined: Wed May 06, 2009 12:13 pm

Top

Could anybody help?

Postby xiaozhe » Thu May 07, 2009 3:43 am

Please......
xiaozhe
Freshman
Freshman
 
Posts: 2
Joined: Wed May 06, 2009 12:13 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests