Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

addIncomingCall in Android TelecomManager not doing anything

Tags:

android

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);
}
}
like image 793
Mark Sheekey Avatar asked Mar 26 '17 09:03

Mark Sheekey


1 Answers

I renamed MyConnectionService to simply MyService - started working. Weird!

like image 76
Mark Sheekey Avatar answered Oct 09 '22 01:10

Mark Sheekey