Class 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(CallConfiguration) 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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidAdds a listener.static AsyncResource<Boolean> configure(CallConfiguration config) Installs the calling identity.static voiddeliverCallEnded(String callId, int reasonOrdinal) static CallAudioRouteWhere call audio is going right now.static CallAvailabilityWhether a call could be rung right now.static intTheCallBridge.CAPABILITY_*mask this platform supports.static intTheCallBridge.PERMISSION_*mask currently granted.static CallSessiongetSession(String callId) The session for a call id, or null when this app has none.static CallSession[]Every call this app currently has.static booleanWhether this platform can show a call in its own call UI.static voidRemoves a listener.static AsyncResource<CallSession> reportIncoming(String callId, CallHandle handle, String displayName, boolean video) Rings an incoming call.static AsyncResource<CallSession> reportOutgoing(String callId, CallHandle handle, String displayName, boolean video) Places an outgoing call in the system UI.static AsyncResource<Integer> requestPermissions(int permissions) Asks for theCallBridge.PERMISSION_*bits inpermissions, resolving with the mask actually granted.static AsyncResource<Boolean> Asks for a particular audio route.static AsyncResource<Boolean> showAudioRoutePicker(String callId) Shows the system's audio route picker for a call.
-
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()TheCallBridge.CAPABILITY_*mask this platform supports. Branch on this rather than on the platform. -
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()TheCallBridge.PERMISSION_*mask currently granted. -
requestPermissions
Asks for theCallBridge.PERMISSION_*bits inpermissions, resolving with the mask actually granted. -
configure
Installs the calling identity. Must precede any reported call. -
reportIncoming
public static AsyncResource<CallSession> reportIncoming(String callId, CallHandle handle, String displayName, boolean video) Rings an incoming call.
callIdmust be a canonicalCallIdand must be the same identifier the far end uses. Allocate one withCallId.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 -- seecom.codename1.call.voip.VoipPush. -
reportOutgoing
public static AsyncResource<CallSession> reportOutgoing(String callId, CallHandle handle, String displayName, boolean video) Places an outgoing call in the system UI. -
getSession
The session for a call id, or null when this app has none. -
getSessions
Every call this app currently has. -
getAudioRoute
Where call audio is going right now. -
setAudioRoute
Asks for a particular audio route. -
showAudioRoutePicker
Shows the system's audio route picker for a call. -
addActionListener
Adds a listener. Every method arrives on the EDT. -
removeActionListener
Removes a listener. -
deliverCallEnded
-