I'm trying to use the native Android incoming call UI. I've got a connectionService and I've succesfully registered a phone Account. But nothing at all happens after I call the method addNewIncomingCall. Any ideas of what I'm missing?
Manifest...
<service
android:name=".MyConnectionService"
android:label="example"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
<intent-filter>
<action android:name="android.telecom.ConnectionService"/>
</intent-filter>
</service>
Activity...
TelecomManager tm = (TelecomManager) getSystemService(Context.TELECOM_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(
new ComponentName(this.getApplicationContext(), MyConnectionService.class),
"example");
PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "example").setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER).build();
tm.registerPhoneAccount(phoneAccount);
Bundle extras = new Bundle();
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, mNumber.getText().toString(), null);
extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri);
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle);
tm.addNewIncomingCall(phoneAccountHandle, extras);
}
MyConnectionService where I'm hoping to at least see something in Log generated by onCreateIncomingConnection
@RequiresApi(api = Build.VERSION_CODES.M)
public class MyConnectionService extends ConnectionService {
private static String TAG = "MyConnectionService";
public MyConnectionService() {
}
@Override
public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
Log.i(TAG,"onCreateIncomingConnection");
return super.onCreateIncomingConnection(connectionManagerPhoneAccount, request);
}
}
I renamed MyConnectionService to simply MyService - started working. Weird!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With