Reputation: 16837
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 ?
Upvotes: 1
Views: 197
Reputation: 1786
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);
}
}
Upvotes: 1