我正在嘗試使用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擴展了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?
uj5u.com熱心網友回復:
您需要在onShowIncomingCallUi方法中顯示您的來電UI.自我管理的ConnectionService API旨在用于呼叫想要提供自己完整的用于呼叫的UI的應用,但仍希望與Android中的移動呼叫共存.uj5u.com熱心網友回復:
樓主,你好,請問你這個有完整的流程,或者demo?不是很理解你ConnectionService 邏輯轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/6987.html
標籤:其他技術討論專區
上一篇:ArcGIS10.2版本,運行ArcToolbox閃退
下一篇:質量流量計的作業原理
