gpt4 book ai didi

java - 如何使用 ConnectionService 获取 Call UI Presentation

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:14:17 24 4
gpt4 key购买 nike

我正在尝试使用 ConnectionService 从 FCM 通知中呈现 ConnectionService 提供的调用 UI。我缺少什么来完成这个?按照 https://developer.android.com/guide/topics/connectivity/telecom/selfManaged 上的步骤操作我添加了:

<uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>

<service android:name=".SparrowConnectionService"
android:label="@string/connection_service_label"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
</intent-filter>
</service>

当我收到 FCM 通知时,我会:

TelecomManager telecomManager = (TelecomManager)this.getSystemService(Context.TELECOM_SERVICE);
String packageName = getApplicationContext().getPackageName();
String className = SparrowConnectionService.class.getName();
ComponentName componentName = new ComponentName(packageName, className);
PhoneAccountHandle accountHandle= new PhoneAccountHandle(componentName, "testID");

PhoneAccount account = PhoneAccount.builder(accountHandle, getApplicationContext().getString(R.string.connection_service_label))
.setCapabilities(PhoneAccount.CAPABILITY_SELF_MANAGED)
.build();
telecomManager.registerPhoneAccount(account);

Bundle extras = new Bundle();
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, accountHandle);
extras.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.STATE_BIDIRECTIONAL);
telecomManager.addNewIncomingCall(accountHandle, extras);

这成功触发了我的 ConnectService 的 onCreateIncomingConnection 方法(CallConnection extends Connection)

@Override
public Connection onCreateIncomingConnection(PhoneAccountHandle connectionManagerPhoneAccount, ConnectionRequest request) {
Log.d(TAG, "onCreateIncomingConnection");
CallConnection connection = new CallConnection(getApplicationContext());
connection.setConnectionProperties(Connection.PROPERTY_SELF_MANAGED);
connection.setCallerDisplayName("TestID", TelecomManager.PRESENTATION_ALLOWED);

Bundle extras = new Bundle();
extras.putBoolean(Connection.EXTRA_ANSWERING_DROPS_FG_CALL, true);
extras.putString(Connection.EXTRA_CALL_SUBJECT, "Test call subject text");
connection.putExtras(extras);
return connection;
}

这会调用我的 CallConnection 的 onShowIncomingCallUi 方法,但不显示任何 UI。如何显示 UI?

最佳答案

您需要在 onShowIncomingCallUi 方法中显示您的来电 UI。 self 管理的 ConnectionService API 旨在用于调用希望提供自己的完整调用 UI,但仍希望与 Android 中的移动调用共存的应用程序。

关于java - 如何使用 ConnectionService 获取 Call UI Presentation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51032423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com