This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
/
ReceiveCallEventsActivityJava.java
71 lines (58 loc) · 2.75 KB
/
ReceiveCallEventsActivityJava.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package com.vonage.sample.channel.voice;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.PersistableBundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import com.nexmo.client.NexmoCall;
import com.nexmo.client.NexmoCallEventListener;
import com.nexmo.client.NexmoCallHandler;
import com.nexmo.client.NexmoMember;
import com.nexmo.client.NexmoCallMemberStatus;
import com.nexmo.client.NexmoClient;
import com.nexmo.client.NexmoMediaActionState;
import com.nexmo.client.request_listener.NexmoApiError;
import com.nexmo.client.request_listener.NexmoRequestListener;
import timber.log.Timber;
public class ReceiveCallEventsActivityJava extends AppCompatActivity {
private NexmoCallEventListener callEventListener = new NexmoCallEventListener() {
@Override
public void onMemberStatusUpdated(NexmoCallMemberStatus $memberStatus, NexmoMember nexmoMember) {
Timber.d("onMemberStatusUpdated(): status: " + $memberStatus + " nexmoMember: " + nexmoMember);
}
@Override
public void onMuteChanged(NexmoMediaActionState muteState, NexmoMember nexmoMember) {
Timber.d("NexmoMediaActionState(): muteState: " + muteState + ", nexmoMember: " + nexmoMember);
}
@Override
public void onEarmuffChanged(NexmoMediaActionState earmuffState, NexmoMember nexmoMember) {
Timber.d("onEarmuffChanged(): earmuffState: " + earmuffState + ", nexmoMember: " + nexmoMember);
}
@Override
public void onDTMF(String digit, NexmoMember nexmoMember) {
Timber.d("onDTMF(): digit:" + digit + ", nexmoMember: " + nexmoMember);
}
};
private NexmoRequestListener<NexmoCall> callListener = new NexmoRequestListener<NexmoCall>() {
@Override
public void onSuccess(@Nullable NexmoCall nexmoCall) {
Timber.d("Call started: " + nexmoCall.toString());
nexmoCall.addCallEventListener(callEventListener);
}
@Override
public void onError(@NonNull NexmoApiError apiError) {
Timber.d("Error: Unable to start a call " + apiError.getMessage());
}
};
@SuppressLint("MissingPermission")
@Override
public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
// No need for client initialization here. Client initialization is already done in BaseApplication class.
// new NexmoClient.Builder().build(this);
NexmoClient client = NexmoClient.get();
client.login("JWT token");
client.call("123456", NexmoCallHandler.IN_APP, callListener);
}
}