Answer incoming call using android.telecom and InCallService

How do you get notified about, and acquire instances of GSM Calls

First, the user will need to select your app as the default Phone app. Refer to Replacing default Phone app on Android 6 and 7 with InCallService for a way to do that.

You also need to define an InCallService implementation the system will bind to and notify you about the call:

<service
    android:name=".CallService"
    android:permission="android.permission.BIND_INCALL_SERVICE">
    <meta-data
        android:name="android.telecom.IN_CALL_SERVICE_UI"
        android:value="true" />
    <intent-filter>
        <action android:name="android.telecom.InCallService" />
    </intent-filter>
</service>

There you should handle at least onCallAdded (set up listeners on Call, start your UI – activity – for the call) and onCallRemoved (remove listeners).

How does one answer these calls

If the user wants to answer the call, you need to invoke the method Call#answer(int) with VideoProfile.STATE_AUDIO_ONLY for example.

What is the life-cycle of the callbacks on this class

Check out Call.Callback for events that can happen with a single call.

Does Google provide any actual tutorial for this that I haven’t found

I don’t know about Google, but you can check out my simplified example https://github.com/arekolek/simple-phone

Leave a Comment