public class DistributedCallManager extends Object
Applications can use the methods provided in this class to perform basic call management, including obtaining the
current call state, registering and deregistering call components, and manages incoming and outgoing calls. Before
managing calls, applications must call DistributedCallManager#getInstance(Context) to obtain a
DistributedCallManager instance.
Some methods of this class are permission-protected. If your application is not granted the required permission, access to these protected methods is denied. The required permissions are provided in the description of a specific method.
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addObserver(CallStateObserver observer,
int mask) |
Adds an observer to monitor call service state changes.
|
boolean |
dial(String number,
boolean isVideoCall) |
Makes a call.
|
void |
displayCallScreen(boolean showDialpad) |
Switches the call screen to the foreground.
|
int |
getCallState() |
Obtains the call state.
|
static DistributedCallManager |
getInstance(Context context) |
Obtains an instance of
DistributedCallManager. |
boolean |
hasCall() |
Checks whether a call is ongoing.
|
boolean |
hasVoiceCapability() |
Checks whether a device supports voice calls.
|
boolean |
isVideoCallingEnabled() |
Checks whether video calling is enabled on this device.
|
void |
removeObserver(CallStateObserver observer) |
Removes an observer to cancel monitoring call service state changes.
|
public static DistributedCallManager getInstance(Context context)
DistributedCallManager.context - Indicates the context of the application.DistributedCallManager.public boolean hasCall()
true if at least one call is not in the CallStateObserver#CALL_STATE_IDLE
state; returns false otherwise.public boolean dial(String number, boolean isVideoCall)
Applications must have the SystemPermission.PLACE_CALL permission to call this method.
number - Indicates the called number.isVideoCall - Indicates whether the call to be made is a video call.
The value false indicates a voice call.true if the call request is successful; returns false otherwise.
Note that the value true indicates only the successful processing of the request; it does not mean
that the call is or can be connected.public void displayCallScreen(boolean showDialpad)
The system performs the switching only if there is an ongoing call.
showDialpad - Indicates whether the dialer is displayed on the call screen.public int getCallState()
If an incoming call is ringing or waiting, the system returns CallStateObserver#CALL_STATE_RINGING.
If at least one call is in the active, hold, or dialing state, the system returns
CallStateObserver#CALL_STATE_OFFHOOK.
In other cases, the system returns CallStateObserver#CALL_STATE_IDLE.
public boolean hasVoiceCapability()
The system checks whether the device has the capability to initiate a circuit switching (CS) or IP multimedia
subsystem domain (IMS) call on a telephone service network. If the device supports only packet switching
(even if the device supports OTT calls), false is returned.
true if the device supports voice calls; returns false otherwise.public void addObserver(CallStateObserver observer, int mask)
observer - Indicates a CallStateObserver instance to add.mask - Indicates the call service state to monitor. The state is indicated by the flag bit or combination
starting with CallStateObserver OBSERVE_.SecurityException - Throws this exception if the application does not have
the ohos.permission.GET_TELEPHONY_STATE permission.public void removeObserver(CallStateObserver observer)
After the observer added by running addObserver(ohos.dcall.CallStateObserver,int) is deleted,
the system no longer receives call service state changes.
observer - Indicates a CallStateObserver instance to delete.public boolean isVideoCallingEnabled()
true if video calling is enabled; returns false otherwise.