Skip to content

Commit 8b4445f

Browse files
committed
update teams call
1 parent 377c1bc commit 8b4445f

File tree

5 files changed

+236
-421
lines changed

5 files changed

+236
-421
lines changed

articles/communication-services/quickstarts/voice-video-calling/get-started-call-to-teams-user.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ titleSuffix: An Azure Communication Services quickstart
44
description: In this quickstart, you learn how to make a call to Teams user with the Azure Communication Calling SDK.
55
author: ruslanzdor
66
ms.author: ruslanzdor
7-
ms.date: 00/19/2023
7+
ms.date: 07/19/2023
88
ms.topic: quickstart
99
ms.service: azure-communication-services
1010
ms.subservice: calling
@@ -36,7 +36,7 @@ In results we'll are able to find "ID" field
3636
```
3737

3838
Or the same ID could be found in [Azure Portal](https://aka.ms/portal) in Users tab:
39-
![portal-user-id](/includes/teams-user/portal-user-id.png)
39+
![User Object ID in Azure Portal](./includes/teams-user/portal-user-id.png)
4040

4141
::: zone pivot="platform-web"
4242
[!INCLUDE [Calling with JavaScript](./includes/teams-user/teams-user-javascript.md)]

articles/communication-services/quickstarts/voice-video-calling/includes/teams-user/teams-user-android.md

Lines changed: 46 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
---
2-
title: Quickstart - Join a Teams meeting from an Android app
3-
description: In this tutorial, you learn how to join a Teams meeting using the Azure Communication Services Calling SDK for Android
4-
author: chpalm
5-
ms.author: rifox
6-
ms.date: 03/10/2021
2+
title: Quickstart - How to call to Teams user from an Android app
3+
description: In this tutorial, you learn how to make a call to Teams user using the Azure Communication Services Calling SDK for Android
4+
author: ruslanzdor
5+
ms.author: ruslanzdor
6+
ms.date: 07/19/2023
77
ms.topic: include
88
ms.service: azure-communication-services
99
---
1010

11-
In this quickstart, you'll learn how to join a Teams meeting using the Azure Communication Services Calling SDK for Android.
12-
1311
## Sample Code
14-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-android-quickstarts/tree/main/join-call-to-teams-meeting).
12+
13+
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-android-quickstarts/tree/main/Add%20Voice%20Calling).
1514

1615
## Prerequisites
1716

@@ -33,12 +32,12 @@ Replace code in activity_main.xml with following snippet. The text box will be u
3332
tools:context=".MainActivity">
3433

3534
<EditText
36-
android:id="@+id/teams_meeting_link"
35+
android:id="@+id/callee_id"
3736
android:layout_width="match_parent"
3837
android:layout_height="wrap_content"
3938
android:ems="10"
40-
android:hint="Teams meeting link"
41-
android:inputType="textUri"
39+
android:hint="Callee Id"
40+
android:inputType="textPersonName"
4241
android:layout_marginTop="100dp"
4342
android:layout_marginHorizontal="20dp"
4443
app:layout_constraintEnd_toEndOf="parent"
@@ -48,17 +47,17 @@ Replace code in activity_main.xml with following snippet. The text box will be u
4847
<LinearLayout
4948
android:layout_width="match_parent"
5049
android:layout_height="wrap_content"
51-
android:layout_marginBottom="70dp"
50+
android:layout_marginBottom="46dp"
5251
android:gravity="center"
5352
app:layout_constraintBottom_toBottomOf="parent"
5453
app:layout_constraintEnd_toEndOf="parent"
5554
app:layout_constraintStart_toStartOf="parent">
5655

5756
<Button
58-
android:id="@+id/join_meeting_button"
57+
android:id="@+id/call_button"
5958
android:layout_width="wrap_content"
6059
android:layout_height="wrap_content"
61-
android:text="Join Meeting" />
60+
android:text="Call" />
6261

6362
<Button
6463
android:id="@+id/hangup_button"
@@ -69,23 +68,13 @@ Replace code in activity_main.xml with following snippet. The text box will be u
6968
</LinearLayout>
7069

7170
<TextView
72-
android:id="@+id/call_status_bar"
73-
android:layout_width="wrap_content"
74-
android:layout_height="wrap_content"
75-
android:layout_marginBottom="40dp"
76-
app:layout_constraintBottom_toBottomOf="parent"
77-
app:layout_constraintEnd_toEndOf="parent"
78-
app:layout_constraintStart_toStartOf="parent" />
79-
80-
<TextView
81-
android:id="@+id/recording_status_bar"
71+
android:id="@+id/status_bar"
8272
android:layout_width="wrap_content"
8373
android:layout_height="wrap_content"
84-
android:layout_marginBottom="20dp"
74+
android:layout_marginBottom="16dp"
8575
app:layout_constraintBottom_toBottomOf="parent"
8676
app:layout_constraintEnd_toEndOf="parent"
8777
app:layout_constraintStart_toStartOf="parent" />
88-
8978
</androidx.constraintlayout.widget.ConstraintLayout>
9079
```
9180

@@ -103,6 +92,7 @@ import androidx.core.app.ActivityCompat;
10392

10493
import android.Manifest;
10594
import android.content.pm.PackageManager;
95+
import android.media.AudioManager;
10696
import android.os.Bundle;
10797
import android.widget.Button;
10898
import android.widget.EditText;
@@ -112,20 +102,20 @@ import android.widget.Toast;
112102
import java.util.ArrayList;
113103
import java.util.concurrent.ExecutionException;
114104

105+
import com.azure.android.communication.common.CommunicationIdentifier;
106+
import com.azure.android.communication.common.CommunicationUserIdentifier;
115107
import com.azure.android.communication.calling.Call;
116108
import com.azure.android.communication.calling.CallAgent;
117109
import com.azure.android.communication.calling.CallClient;
118110
import com.azure.android.communication.calling.HangUpOptions;
119-
import com.azure.android.communication.calling.JoinCallOptions;
120111
import com.azure.android.communication.common.CommunicationTokenCredential;
121-
import com.azure.android.communication.calling.TeamsMeetingLinkLocator;
112+
import com.azure.android.communication.calling.StartCallOptions;
122113

123114
public class MainActivity extends AppCompatActivity {
124115
private static final String[] allPermissions = new String[] { Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE };
125116
private static final String UserToken = "<User_Access_Token>";
126117

127-
TextView callStatusBar;
128-
TextView recordingStatusBar;
118+
TextView statusBar;
129119

130120
private CallAgent agent;
131121
private Call call;
@@ -138,50 +128,50 @@ public class MainActivity extends AppCompatActivity {
138128
getAllPermissions();
139129
createAgent();
140130

141-
Button joinMeetingButton = findViewById(R.id.join_meeting_button);
142-
joinMeetingButton.setOnClickListener(l -> joinTeamsMeeting());
131+
Button callButton = findViewById(R.id.call_button);
132+
callButton.setOnClickListener(l -> startCall());
143133

144134
Button hangupButton = findViewById(R.id.hangup_button);
145-
hangupButton.setOnClickListener(l -> leaveMeeting());
135+
hangupButton.setOnClickListener(l -> endCall());
146136

147-
callStatusBar = findViewById(R.id.call_status_bar);
148-
recordingStatusBar = findViewById(R.id.recording_status_bar);
137+
statusBar = findViewById(R.id.status_bar);
138+
139+
setVolumeControlStream(AudioManager.STREAM_VOICE_CALL);
149140
}
150141

151142
/**
152-
* Join Teams meeting
143+
* Start a call
153144
*/
154-
private void joinTeamsMeeting() {
145+
private void startCall() {
155146
if (UserToken.startsWith("<")) {
156147
Toast.makeText(this, "Please enter token in source code", Toast.LENGTH_SHORT).show();
157148
return;
158149
}
159150

160-
EditText calleeIdView = findViewById(R.id.teams_meeting_link);
161-
String meetingLink = calleeIdView.getText().toString();
162-
if (meetingLink.isEmpty()) {
163-
Toast.makeText(this, "Please enter Teams meeting link", Toast.LENGTH_SHORT).show();
151+
EditText calleeIdView = findViewById(R.id.callee_id);
152+
String calleeId = calleeIdView.getText().toString();
153+
if (calleeId.isEmpty()) {
154+
Toast.makeText(this, "Please enter callee", Toast.LENGTH_SHORT).show();
164155
return;
165156
}
166-
167-
JoinCallOptions options = new JoinCallOptions();
168-
TeamsMeetingLinkLocator teamsMeetingLinkLocator = new TeamsMeetingLinkLocator(meetingLink);
169-
call = agent.join(
157+
ArrayList<CommunicationIdentifier> participants = new ArrayList<>();
158+
participants.add(new CommunicationUserIdentifier(calleeId));
159+
StartCallOptions options = new StartCallOptions();
160+
call = agent.startCall(
170161
getApplicationContext(),
171-
teamsMeetingLinkLocator,
162+
participants,
172163
options);
173-
call.addOnStateChangedListener(p -> setCallStatus(call.getState().toString()));
174-
call.addOnIsRecordingActiveChangedListener(p -> setRecordingStatus(call.isRecordingActive()));
164+
call.addOnStateChangedListener(p -> setStatus(call.getState().toString()));
175165
}
176166

177167
/**
178-
* Leave from the meeting
168+
* Ends the call previously started
179169
*/
180-
private void leaveMeeting() {
170+
private void endCall() {
181171
try {
182172
call.hangUp(new HangUpOptions()).get();
183173
} catch (ExecutionException | InterruptedException e) {
184-
Toast.makeText(this, "Unable to leave meeting", Toast.LENGTH_SHORT).show();
174+
Toast.makeText(this, "Unable to hang up call", Toast.LENGTH_SHORT).show();
185175
}
186176
}
187177

@@ -228,31 +218,17 @@ public class MainActivity extends AppCompatActivity {
228218
}
229219

230220
/**
231-
* Shows call status in status bar
221+
* Shows message in the status bar
232222
*/
233-
private void setCallStatus(String status) {
234-
runOnUiThread(() -> callStatusBar.setText(status));
235-
}
236-
237-
/**
238-
* Shows recording status status bar
239-
*/
240-
private void setRecordingStatus(boolean status) {
241-
if (status == true) {
242-
runOnUiThread(() -> recordingStatusBar.setText("This call is being recorded"));
243-
}
244-
else {
245-
runOnUiThread(() -> recordingStatusBar.setText(""));
246-
}
223+
private void setStatus(String status) {
224+
runOnUiThread(() -> statusBar.setText(status));
247225
}
248226
}
249227

250228
```
251229

252230
## Launch the app and join Teams meeting
253231

254-
The app can now be launched using the "Run App" button on the toolbar (Shift+F10). You should see the following:
255-
256-
:::image type="content" source="../../media/android/acs-join-teams-meeting-quickstart.png" alt-text="Screenshot showing the completed application.":::
232+
The app can now be launched using the "Run App" button on the toolbar (Shift+F10). Verify you're able to place calls by calling `8:echo123`. A pre-recorded message plays then repeat your message back to you.
257233

258-
Insert the Teams context into the text box and press *Join Meeting* to join the Teams meeting from within your Communication Services application.
234+
:::image type="content" source="../../media/android/quickstart-android-call-echobot.png" alt-text="Screenshot showing the completed application.":::

0 commit comments

Comments
 (0)