我正在尝试使用 native Android 来电 UI。我有一个 connectionService,我已经成功注册了一个电话帐户。但是在我调用方法 addNewIncomingCall 之后什么也没有发生。对我缺少的东西有什么想法吗?
list ...
<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,我希望至少能在 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);
}
}
最佳答案
我将 MyConnectionService 重命名为简单的 MyService - 开始工作。奇怪!
关于android - Android TelecomManager 中的 addIncomingCall 没有做任何事情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43027292/