3

I am using InCallService for making calls in my app. Its working fine for incoming and outgoing calls. onCallAdded() is called when I receive or make a call.

CallService:

public class CallService extends InCallService {

    Context context;
    InCallService inCallService;
    String number;
    int callType;

    @RequiresApi(api = Build.VERSION_CODES.Q)
    @Override
    public void onCallAdded(Call call) {
        super.onCallAdded(call);

        context = this;
        inCallService = this;

        number = Objects.requireNonNull(call.getDetails().getHandle()).getSchemeSpecificPart();
        callType = call.getDetails().getCallDirection();
    }

    @Override
    public void onCallRemoved(Call call) {
        super.onCallRemoved(call);
    }
}

Manifest.xml

<service
            android:name=".services.CallService"
            android:enabled="true"
            android:exported="true"
            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>

The problem is that I am unable to detect an incoming call when app is already making a call and the call is in ringing state and not connected yet. onCallAdded() is not called in this case. Maybe there is a method in InCallService that detects this scenario. How can I detect call in this scenario. Need Help.

Saify
  • 469
  • 1
  • 5
  • 20

0 Answers0