Код в руководстве для запуска звонок:
Код: Выделить всё
private void startCall() {
Context context = this.getApplicationContext();
EditText callIdView = findViewById(R.id.call_id);
String callId = callIdView.getText().toString();
ArrayList participants = new ArrayList();
List cameras = deviceManager.getCameras();
StartCallOptions options = new StartCallOptions();
if(!cameras.isEmpty()) {
currentCamera = getNextAvailableCamera(null);
currentVideoStream = new LocalVideoStream(currentCamera, context);
LocalVideoStream[] videoStreams = new LocalVideoStream[1];
videoStreams[0] = currentVideoStream;
VideoOptions videoOptions = new VideoOptions(videoStreams);
options.setVideoOptions(videoOptions);
showPreview(currentVideoStream);
}
participants.add(new CommunicationUserIdentifier(callId));
call = callAgent.startCall(
context,
participants,
options);
//Subscribe to events on updates of call state and remote participants
remoteParticipantUpdatedListener = this::handleRemoteParticipantsUpdate;
onStateChangedListener = this::handleCallOnStateChanged;
call.addOnRemoteParticipantsUpdatedListener(remoteParticipantUpdatedListener);
call.addOnStateChangedListener(onStateChangedListener);
}
Код: Выделить всё
private void startCall(String whoCall, String whoCalled) {
Context context = this.getApplicationContext();
ArrayList participants = new ArrayList();
List cameras = deviceManager.getCameras();
StartCallOptions options = new StartCallOptions();
if(!cameras.isEmpty()) {
currentCamera = getNextAvailableCamera(null);
currentVideoStream = new LocalVideoStream(currentCamera, context);
LocalVideoStream[] videoStreams = new LocalVideoStream[1];
videoStreams[0] = currentVideoStream;
VideoOptions videoOptions = new VideoOptions(videoStreams);
options.setVideoOptions(videoOptions);
showPreview(currentVideoStream);
}
participants.add(new CommunicationUserIdentifier(whoCall));
participants.add(new CommunicationUserIdentifier(whoCalled));
call = callAgent.startCall(
context,
participants,
options);
//Subscribe to events on updates of call state and remote participants
remoteParticipantUpdatedListener = this::handleRemoteParticipantsUpdate;
onStateChangedListener = this::handleCallOnStateChanged;
call.addOnRemoteParticipantsUpdatedListener(remoteParticipantUpdatedListener);
call.addOnStateChangedListener(onStateChangedListener);
callButton.setVisibility(View.INVISIBLE);
funStuffButton.setVisibility((View.VISIBLE));
hangupButton.setVisibility(View.VISIBLE);
}
Однако, когда я пытаюсь использовать вещи таким образом, через эмулятор на моем компьютер и APK на моем телефоне, на самом деле ничего не подключается. Я думаю, моя проблема заключается в непонимании того, как токен Портала используется в приложении Android для подключения одного пользователя к другому пользователю.
У меня есть следующие мысли:
- Нужно ли мне, чтобы обе стороны подключались через приложение к одному и тому же токену? Если это так, то как мне сделать так, чтобы один человек позвонил другому человеку?
- Нужно ли мне изменить свой код в отношении того, как я использую токен в рамках инициации вызова? ? Я не понимаю, чем мой код настолько отличается от учебного пособия, что нарушает способ использования токена.
Подробнее здесь: https://stackoverflow.com/questions/792 ... on-service
Мобильная версия