Reputation: 179
I am writing an application which override the default incoming call screen. So I have a button in my application for receiving calls. When user click on the button then the application will accept the call. So far I successful done on this application and can be using in android 2.3.4 or below without any problem. However, when I use the same application in android 2.3.5 , it cant accept the call. So I was wondering if there is another solution to accept call programmatically in android 2.3.5. Thanks in advance for any guidance provide. Below are the code for accept call.
private static void answerPhoneHeadsethook(Context context) {
// Simulate a press of the headset button to pick up the call
Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
context.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));
context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");
}
Upvotes: 2
Views: 3532
Reputation: 2497
Check this guy's update...I think this is what you need! http://androidbridge.blogspot.com/2011/05/how-to-answer-incoming-call-in-android.html
Upvotes: 2
Reputation: 59178
Have a look at http://code.google.com/p/auto-answer/ source code:
AutoAnswer is a very simple android application to answer the phone automatically when it rings. Can be limited to just contacts or starred contacts. Also has a speakerphone option.
http://code.google.com/p/auto-answer/
Upvotes: 1