java.lang.Object | |
↳ | com.salesforce.android.sos.api.Sos |
The main API to interface with the session lifecycle.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | Sos.SessionBuilder | SessionBuilder is used to aid in the construction of an SOS session. | |||||||||
class | Sos.SessionExistsException | Thrown when caller attempts to start an SOS session while one already exists. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static boolean |
addAVListener(SosAVListener listener)
Adds the given listener to all current and future SOS sessions until it is removed.
| ||||||||||
static boolean |
addConnectionListener(SosConnectionListener listener)
Adds the given listener to all current and future SOS sessions until it is removed.
| ||||||||||
static boolean |
addHoldListener(SosHoldListener listener)
Adds the given listener to all current and future SOS sessions until it is removed.
| ||||||||||
static boolean |
addListener(SosListener listener)
Adds the given listener to all current and future SOS sessions until it is removed.
| ||||||||||
static boolean |
addMaskingListener(SosMaskingListener listener)
Adds the given listener to all current and future SOS sessions until it is removed.
| ||||||||||
static boolean |
addNetworkTestListener(SosNetworkTestListener listener)
Adds the given listener to all current and future SOS sessions until it is removed.
| ||||||||||
static boolean |
addShareTypeListener(SosShareTypeListener listener)
Adds the given listener to all current and future SOS sessions until it is removed.
| ||||||||||
static void |
captureExtra(Toast toast)
Manually instruct the SOS framework to add a toast to the captured video stream sent to the
agent.
| ||||||||||
static void |
captureExtra(Dialog dialog)
Manually instruct the SOS framework to add a dialog to the captured video stream sent to the
agent.
| ||||||||||
static void |
endSession(boolean showPrompt)
Ends the currently active SOS session.
| ||||||||||
static SosConfiguration |
getConfiguration()
Retrieve the configuration that was used to start the session.
| ||||||||||
static SosHoldState |
getHoldState()
Get the current Hold state of the session.
| ||||||||||
static String |
getId()
Retrieves the identifier for the current SOS session, if any.
| ||||||||||
static SosShareType |
getInitialShareType()
Get the initial share type for the session based on your
SosConfiguration and the presence
of camera hardware on the end-user's device. | ||||||||||
static SosOptions |
getOptions()
Retrieve the options that were used to start the session.
| ||||||||||
static SosState |
getState()
Retrieve the configuration that was used to start the session.
| ||||||||||
static String |
getVersion()
Returns the SemVer version string for the SDK.
| ||||||||||
static void |
hideKeyboard()
Tells the SOS framework to hide any currently displayed keyboard bitmap.
| ||||||||||
static boolean |
isScreenSharingEnabled()
Get whether screen sharing is currently enabled.
| ||||||||||
static boolean |
isSessionActive()
Checks to see if there is an active SOS session.
| ||||||||||
static boolean |
removeAVListener(SosAVListener listener)
Removes the specified listener object.
| ||||||||||
static boolean |
removeConnectionListener(SosConnectionListener listener)
Removes the specified listener object.
| ||||||||||
static boolean |
removeHoldListener(SosHoldListener listener)
Removes the specified listener object.
| ||||||||||
static boolean |
removeListener(SosListener listener)
Removes the specified listener object.
| ||||||||||
static boolean |
removeMaskingListener(SosMaskingListener listener)
Removes the specified listener object.
| ||||||||||
static boolean |
removeNetworkTestListener(SosNetworkTestListener listener)
Removes the specified listener object.
| ||||||||||
static boolean |
removeShareTypeListener(SosShareTypeListener listener)
Removes the specified listener object.
| ||||||||||
static Sos.SessionBuilder |
session(SosOptions options)
Build a new SOS session.
| ||||||||||
static void |
setAudioEnabled(boolean enabled)
Mute/unmute the customer audio.
| ||||||||||
static void |
setPosition(int x, int y)
Set the position of the Agent's video view in the Service Cloud Console.
| ||||||||||
static void |
setScreenSharingEnabled(boolean enabled)
Turn on/off screen sharing.
| ||||||||||
static void |
setSessionPaused(boolean paused)
Pause/un-pause the session.
| ||||||||||
static void |
setShareType(SosShareType shareType)
Transition from the current share type to another.
| ||||||||||
static void |
setTwoWayVideoEnabled(boolean enabled)
Turn on/off two-way video.
| ||||||||||
static void |
showKeyboard(Rect position)
Tell the SOS framework to display a bitmap representing a keyboard on the screen.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Adds the given listener to all current and future SOS sessions until it is removed. Listeners may only be added once, multiple calls for a given listener will not add the listener multiple times.
See SosAVListener
for usage instructions.
Note that this listener instance is strongly referenced, and thus must be explicitly removed
by calling removeAVListener(SosAVListener)
when you no longer wish to receive events.
Failure to remove a listener can result in a memory leak in your application.
listener | the listener to add. |
---|
Adds the given listener to all current and future SOS sessions until it is removed. Listeners may only be added once, multiple calls for a given listener will not add the listener multiple times.
See SosConnectionListener
for usage instructions.
Note that this listener instance is strongly referenced, and thus must be explicitly removed
by calling removeConnectionListener(SosConnectionListener)
when you no longer wish to
receive events. Failure to remove a listener can result in a memory leak in your
application.
listener | The listener to add. |
---|
Adds the given listener to all current and future SOS sessions until it is removed. Listeners may only be added once, multiple calls for a given listener will not add the listener multiple times.
See SosHoldListener
for usage instructions.
Note that this listener instance is strongly referenced, and thus must be explicitly removed
by calling removeHoldListener(SosHoldListener)
when you no longer wish to receive events.
Failure to remove a listener can result in a memory leak in your application.
listener | the listener to add. |
---|
Adds the given listener to all current and future SOS sessions until it is removed. Listeners may only be added once, multiple calls for a given listener will not add the listener multiple times.
Note that this listener instance is strongly referenced, and thus must be explicitly removed
by calling removeListener(SosListener)
when you no longer wish to receive events
regarding SOS sessions. Failure to remove a listener can result in a memory leak in your
application.
listener | The listener to add. |
---|
Adds the given listener to all current and future SOS sessions until it is removed. Listeners may only be added once, multiple calls for a given listener will not add the listener multiple times.
See SosMaskingListener
for usage instructions.
Note that this listener instance is strongly referenced, and thus must be explicitly removed
by calling removeMaskingListener(SosMaskingListener)
when you no longer wish to receive events.
Failure to remove a listener can result in a memory leak in your application.
listener | The listener to add. |
---|
Adds the given listener to all current and future SOS sessions until it is removed. Listeners may only be added once, multiple calls for a given listener will not add the listener multiple times.
See SosNetworkTestListener
for usage instructions.
Note that this listener instance is strongly referenced, and thus must be explicitly removed
by calling removeNetworkTestListener(SosNetworkTestListener)
when you no longer wish
to receive events. Failure to remove a listener can result in a memory leak in your
application.
listener | the listener to add. |
---|
Adds the given listener to all current and future SOS sessions until it is removed. Listeners may only be added once, multiple calls for a given listener will not add the listener multiple times.
See SosShareTypeListener
for usage instructions.
Note that this listener instance is strongly referenced, and thus must be explicitly removed
by calling removeShareTypeListener(SosShareTypeListener)
when you no longer wish
to receive events. Failure to remove a listener can result in a memory leak in your
application.
listener | the listener to add. |
---|
Manually instruct the SOS framework to add a toast to the captured video stream sent to the agent.
Toasts present to the user will not be captured by default, and must be explicitly passed to the framework via this method in order to be drawn into the captured video.
Note that the Toast must not be null.
toast | The Toast instance that should be included in the captured video stream. |
---|
Manually instruct the SOS framework to add a dialog to the captured video stream sent to the agent. Dialogs present to the user will not be captured by default, and must be explicitly passed to the framework via this method in order to be drawn into the captured video.
A common pitfall is to create your dialog and immediately pass reference to Sos. In some cases this may not work. For example:
MyDialogFragment myDialog = new MyDialogFragment();
myDialog.show(getFragmentManager());
Sos.captureExtra(myDialog.getDialog());
Will not work. Either getDialog will return null or the view will not be ready yet. In cases such as this it is recommended you wait until the DialogFragment is created to pass reference. For example:
// From within `MyDialogFragment`
@Override
public Dialog onCreateDialog (Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
Sos.captureExtra(dialog);
return dialog;
}
You will observe odd behavior if you allow your Dialog to leak the app window.
A common case this comes up is when in a call, if you rotate your device, the dialog disappears, but the agent continues to see the dialog and there is seemingly no way to get rid of it. Check your device logs and ensure that you are not leaking the window. You will see something like
android.view.WindowLeaked: Activity com.yourpackage.YourActivity has leaked window com.android.internal...
Generally, this means you did not dismiss your dialog when you rotated your device, and since Sos holds
a reference to it, bad things happen. The most common fix for this problem is to dismiss the dialog
when your activity stops. Or, use a DialogFragment instead.dialog | The dialog instance that should be included in the captured video stream. |
---|
Ends the currently active SOS session. If there is no active session then this method will have no effect.
showPrompt | Used to determine whether or not the user should be prompted to confirm
before ending the session. If false is passed the session will simply
end without prompting the user.
|
---|
Retrieve the configuration that was used to start the session.
Get the current Hold state of the session.
Retrieves the identifier for the current SOS session, if any.
WaitingForAgent
, prior to this the returned id will be null.
Get the initial share type for the session based on your SosConfiguration
and the presence
of camera hardware on the end-user's device.
For example, if your SosConfiguration
has the default share type set to
FrontFacingCamera
but the user's device does not have a front camera, then
the next available camera device will be chosen. If there are no camera devices present on the
device, this method will return ScreenSharing
.
This method will return null unless the session has been started.
Retrieve the options that were used to start the session.
Retrieve the configuration that was used to start the session.
Returns the SemVer version string for the SDK.
Tells the SOS framework to hide any currently displayed keyboard bitmap.
Get whether screen sharing is currently enabled.
Checks to see if there is an active SOS session. An "active" session is one that has been started and has connected to the SOS Service, but is not yet ended.
Removes the specified listener object. Does nothing if the listener was not previously added
with addAVListener(SosAVListener)
.
See SosAVListener
for usage instructions.
listener | the listener to remove. |
---|
Removes the specified listener object. Does nothing if the listener was not previously added
with addConnectionListener(SosConnectionListener)
.
See SosConnectionListener
for usage instructions.
listener | The listener to remove. |
---|
Removes the specified listener object. Does nothing if the listener was not previously added
with addHoldListener(SosHoldListener)
.
See SosHoldListener
for usage instructions.
listener | the listener to remove. |
---|
Removes the specified listener object. Does nothing if the listener was not previously added
with addListener(SosListener)
.
listener | The listener to remove. |
---|
Removes the specified listener object. Does nothing if the listener was not previously added
with addMaskingListener(SosMaskingListener)
.
See SosMaskingListener
for usage instructions.
listener | The listener to remove. |
---|
Removes the specified listener object. Does nothing if the listener was not previously added
with addNetworkTestListener(SosNetworkTestListener)
.
See SosNetworkTestListener
for usage instructions.
listener | the listener to remove. |
---|
Removes the specified listener object. Does nothing if the listener was not previously added
with addShareTypeListener(SosShareTypeListener)
.
See SosShareTypeListener
for usage instructions.
listener | the listener to remove. |
---|
Build a new SOS session.
A session may be started by calling the start(Activity)
method after all of your desired parameters have been set.
options | The options for connecting the session. |
---|
Sos.SessionBuilder
instance
Mute/unmute the customer audio.
enabled | whether or not the customer audio should be transmitted. |
---|
Set the position of the Agent's video view in the Service Cloud Console.
NOTE: The coordinate value you pass here will move the center of the agent's
video container in the Service Cloud Console to that point.
This is done to allow a custom UI with a different window size to look more aligned by being
center aligned. e.g. A view on the phone that is 500dp * 500dp would be substantially larger
than the agent window in the Service Cloud Console. They will look more in-line with each
other of the center of the views are on the same point of the screen.
If you are keeping two views in-line with each other, the recommended way to call this method
looks like
Sos.setPosition(myView.getWidth() / 2 + myView.getX(), myView.getHeight() / 2 + myView.getY());
If you simply want to move the agent window, you are free to do so however you please.
x | The center-based x-coordinate. |
---|---|
y | The center-based y-coordinate. |
Turn on/off screen sharing. The default behavior of SOS is to enable screen sharing during a session. However screen sharing can be enabled/disabled at any time.
enabled | whether or not to capture and send the device screen over SOS. |
---|
Pause/un-pause the session. Pausing the session will halt the transmission of video and audio between the user and the agent.
paused | True if the session must be paused, false to un-pause the session. |
---|
Transition from the current share type to another.
shareType | The share type to transition to. |
---|
Turn on/off two-way video. twoWayVideo(boolean)
must be set to allow two-way video before starting the session.
enabled | whether or not to broadcast the customers camera rather than their phone screen. |
---|
Tell the SOS framework to display a bitmap representing a keyboard on the screen.
position | the area on the screen covered by the keyboard (in pixels). A value of null indicates that the keyboard covers the entire screen. |
---|