1

I want to learn how calls can be accepted programmatically in Android. For example, this app accepts calls on a hand wave motion.

I know how to dial a call from an app, but what API is available in Android to accept a call ?

Jake
  • 16,329
  • 50
  • 126
  • 202

1 Answers1

1

Maybe you can check out a tutorial like this or this and look into Broadcast Receivers.

For answering calls, check out this and this.

Doing so might require you to add a reciever to your Android Manifest and then implementing the BroadcastReceiver.

Ex:

Android Manifest

<application>
  .....
  <receiver android:name=".ServiceReceiver">
    <intent-filter>
      <action android:name="android.intent.action.PHONE_STATE" />
    </intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.READ_PHONE_STATE">
</uses-permission>

ServiceReceiver

public class ServiceReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
    MyPhoneStateListener phoneListener=new MyPhoneStateListener();
    TelephonyManager telephony = (TelephonyManager) 
    context.getSystemService(Context.TELEPHONY_SERVICE);
    telephony.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
  }
}
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
erad
  • 1,766
  • 2
  • 17
  • 26
  • I need to accept the call .. not just detect whether the phone is ringing – Jake Sep 14 '14 at 04:00
  • Is there a more recent tutorial ? Does the code for answering calls work in Android 4.4.2 (it was posted in 2010) ? – Jake Sep 14 '14 at 04:21
  • Maybe you can check out [this answer](http://stackoverflow.com/questions/15481524/how-to-programatically-answer-end-a-call-in-android-4-1). – erad Sep 14 '14 at 04:26