public final class Calls
- Object
- Calls
System call integration: the entry point for reporting calls to the operating system and hearing what the user does with them.
if (!Calls.isSupported()) {
return; // fall back to an in-app call screen
}
Calls.configure(new CallConfiguration().displayName("Acme Talk"));
Calls.addActionListener(new CallActionAdapter() {
public void answerRequested(String callId, CallAction action) {
signalling.accept(callId);
}
public void audioSessionActivated(CallAudioSession session) {
media.start(); // here, not in answerRequested
}
public void providerReset() {
media.stopEverything();
}
});
Everything here is static because there is one operating system and one call provider per app.
Order matters
configure must run before any call is reported. On Android an
unconfigured provider makes TelecomManager ignore reported calls
silently.
Every callback arrives on the EDT
Unlike some other families in this framework, that is true here without exception: an action from the system is a user-interface event and there is nothing to gain by delivering it anywhere else.
Methods
Inherited methods
Method details
isSupported
public static boolean isSupported()Whether this platform can show a call in its own call UI.
False on the ports that have no such concept, and on Android below API 26. An app must have a fallback; there is no way to make a desktop show a lock-screen call.
getCapabilities
public static int getCapabilities()CallBridge.CAPABILITY_* mask this platform supports. Branch on
this rather than on the platform.getAvailability
public static CallAvailability getAvailability()Whether a call could be rung right now.
Different from isSupported(): an emergency call, or another app’s
call, makes this refuse on a platform that supports calling
perfectly. Check it before telling a caller their call is ringing.
getGrantedPermissions
public static int getGrantedPermissions()CallBridge.PERMISSION_* mask currently granted.requestPermissions
public static AsyncResource<Integer> requestPermissions(int permissions)CallBridge.PERMISSION_* bits in permissions,
resolving with the mask actually granted.configure
public static AsyncResource<Boolean> configure(CallConfiguration config)reportIncoming
public static AsyncResource<CallSession> reportIncoming(String callId, CallHandle handle, String displayName, boolean video)Rings an incoming call.
callId must be a canonical CallId and must be the same identifier
the far end uses. Allocate one with CallId.random() for a call
learned over the app’s own connection; a call that arrived as a VoIP
push already has one and must not be re-reported here – see
com.codename1.call.voip.VoipPush.
reportOutgoing
public static AsyncResource<CallSession> reportOutgoing(String callId, CallHandle handle, String displayName, boolean video)getSession
public static CallSession getSession(String callId)getSessions
public static CallSession[] getSessions()getAudioRoute
public static CallAudioRoute getAudioRoute()setAudioRoute
public static AsyncResource<Boolean> setAudioRoute(CallAudioRoute r)showAudioRoutePicker
public static AsyncResource<Boolean> showAudioRoutePicker(String callId)addActionListener
public static void addActionListener(CallActionListener l)removeActionListener
public static void removeActionListener(CallActionListener l)deliverCallEnded
public static void deliverCallEnded(String callId, int reasonOrdinal)