Possible Duplicate:
How to intercept incoming calls android 2.3.x
I am making an app that overrides the default telephone screen and I it need to be compatible with Android 2.3 onwards.
Currently I have this code:
private void answerCallAidl() throws RemoteException {
// telephonyService.silenceRinger(); -------not work on 2.3
// telephonyService.answerRingingCall(); -------not work on 2.3
Intent headSetUnPluggedintent = new Intent(Intent.ACTION_HEADSET_PLUG);
headSetUnPluggedintent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
headSetUnPluggedintent.putExtra("state", 1); // 0 = unplugged 1 = Headset with microphone 2 = Headset without microphone
headSetUnPluggedintent.putExtra("name", "Headset");
// TODO: Should we require a permission?
sendOrderedBroadcast(headSetUnPluggedintent, null);
Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK));
sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");
// froyo and beyond trigger on buttonUp instead of buttonDown
Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK));
sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}
private void ignoreCallAidl() throws RemoteException {
// telephonyService.silenceRinger(); -------not work on 2.3
// telephonyService.endCall(); -------not work on 2.3
Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK));
sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}
My problems are:
- I am unable to reject incoming calls.
- It does not work on version 2.3.5.
- I want my app to replace the default telephone screen.
I would appreciate very much any help.