The Cisco Webex™ Android SDK Version 3.0.0
The Cisco Webex Android SDK makes it easy to integrate secure and convenient Cisco Webex messaging and calling features in your Android apps.
This SDK is built with Android SDK Tools 29 and requires Android API Level 24 or later.
For creating a new app integration, new client id generation, etc. visit App Registration For Mobile SDK v3
- Advantages
- Notes
- Integration
- Usage
- Multi Stream
- CUCM
- Migration Guide
- Sample App
- API Reference
- License
- Unified feature set: Meeting, Messaging, CUCM calling.
- Greater feature velocity and in parity with the Webex mobile app.
- Easier for developers community: SQLite is bundled for automatic data caching.
- Greater quality as it is built on a more robust infrastructure.
- Integrations created earlier will not work with v3 because they are not entitled to the scopes required by v3. You can either raise a support request to enable these scopes for your appId or you could create a new Integration that's meant to be used for v3. This does not affect Guest Issuer JWT token-based sign-in.
- We do not support external auth code login anymore.
- Currently all resource ids that are exposed from the SDK are barebones GUIDs. You cannot directly use these ids to make calls to webexapis.com. You'll need to call
Webex.base64Encode(type: ResourceType, resource: String, handler: CompletionHandler<String>)
to get a base64 encoded resource. However, you're free to interchange between base64 encoded resource ids and barebones GUID while providing them as input to the SDK APIs. - You can add
android:extractNativeLibs="true"
inside your<application>
tag in your Manifest file to reduce the generated apk size.
-
Put AAR file in libs folder of your Android project
-
Open the project level Gradle file and add the following lines under the repositories tag, which is nested under allprojects.
allprojects { repositories { flatDir { dirs 'aars'} //add this line } }
-
Add the following dependency in module level Gradle file and press sync-now
implementation files('libs/WebexSDK.aar')
-
Add the following repository to your top-level
build.gradle
file:allprojects { repositories { maven { url 'https://devhub.cisco.com/artifactory/webexsdk/' } } }
-
Add the
webex-android-sdk
library as a dependency for your app in thebuild.gradle
file:dependencies { implementation 'com.ciscowebex:androidsdk:3.0.0@aar' }
To use the SDK, you will need Cisco Webex integration credentials. If you do not already have a Cisco Webex account, visit the Cisco Webex for Developers portal to create your account and register an integration. Your app will need to authenticate users via an OAuth grant flow for existing Cisco Webex users or a JSON Web Token for guest users without a Cisco Webex account.
See the Android SDK area of the Cisco Webex for Developers site for more information about this SDK.
Here are some examples of how to use the Android SDK in your app.
-
Create a new
Webex
instance using Webex ID authentication (OAuth-based):val clientId: String = "YOUR_CLIENT_ID" val clientSecret: String = "YOUR_CLIENT_SECRET" val redirectUri: String = "https://webexdemoapp.com" val email = "EMAIL_ID_OF_END_USER" // Get email id from end user val authenticator: OAuthWebViewAuthenticator = OAuthWebViewAuthenticator(clientId, clientSecret, redirectUri, email) val webex = Webex(application, authenticator) webex.enableConsoleLogger(true) webex.setLogLevel(LogLevel.VERBOSE) // Highly recommended to make this end-user configurable incase you need to get detailed logs. webex.initialize(CompletionHandler { result -> if (result.error != null) { //already authorised } else { authenticator.authorize(loginWebview, CompletionHandler { result -> if (result.error != null) { //Handle the error }else{ //Authorization successful } }) } })
-
Create a new
Webex
instance using JWT authenticationval token: String = "jwt_token" val authenticator: JWTAuthenticator = JWTAuthenticator() val webex = Webex(application, authenticator) webex.initialize(CompletionHandler { result -> if (result.error != null) { //already authorised } else { authenticator.authorize(token, CompletionHandler { result -> if (result.error != null) { //Handle the error }else{ //Authorization successful } }) } })
-
Create a new Cisco Webex space, add users to the space, and send a message:
// Create a Cisco Webex space: webex.spaces.create("Hello World", null, CompletionHandler<Space?> { result -> if (result.isSuccessful) { val space = result.data } else { val error= result.error } }) // Add a user to a space: webex.memberships.create("spaceId", null, "[email protected]", true, CompletionHandler<Membership?> { result -> if (result.isSuccessful) { val space = result.data } else { val error= result.error } }) // Send a message to a space: webex.messages.postToSpace("spaceId", Message.Text.plain("Hello"), null, null, CompletionHandler<Message> { result -> if(result != null && result.isSuccessful){ val message = result.data } })
-
Make an outgoing call:
webex.phone.dial("[email protected]", MediaOption.audioVideo(local, remote), CompletionHandler { val call = it.data call?.setObserver(object : CallObserver { override fun onConnected(call: Call?) { super.onConnected(call) } override fun onDisconnected(event: CallDisconnectedEvent?) { super.onDisconnected(event) } override fun onFailed(call: Call?) { super.onFailed(call) } }) })
-
Receive a call:
webex.phone.setIncomingCallListener(object : Phone.IncomingCallListener { override fun onIncomingCall(call: Call?) { call?.answer(MediaOption.audioOnly(), CompletionHandler { if (it.isSuccessful){ // ... } }) } })
-
Make a space call:
webex.phone().dial(spaceId, MediaOption.audioVideoSharing(Pair(localView,remoteView), screenShareView), CompletionHandler { result -> if (result.isSuccessful) { result.data?.let { _call -> // Space call connected. Set observer to listen for call events call.setObserver(object : CallObserver { override fun onConnected(call: Call?) { } override fun onRinging(call: Call?) { } override fun onWaiting(call: Call?, reason: Call.WaitReason?) { } override fun onDisconnected(event: CallObserver.CallDisconnectedEvent?) { } override fun onInfoChanged(call: Call?) { } override fun onMediaChanged(event: CallObserver.MediaChangedEvent?) { } override fun onCallMembershipChanged(event: CallObserver.CallMembershipChangedEvent?) { } override fun onScheduleChanged(call: Call?) { } }) } } else { result.error?.let { errorCode -> // Error in space call } } });
-
Screen sharing:
webex.phone.dial("spaceId", MediaOption.audioVideoSharing(Pair(localView, remoteView), screenShareView), CompletionHandler { if(it.isSuccessful){ val call = it.data call?.setObserver(object :CallObserver{ override fun onConnected(call: Call?) { super.onConnected(call) } // ... override fun onMediaChanged(event: CallObserver.MediaChangedEvent?) { event?.let { _event -> val _call = _event.getCall() when (_event) { is CallObserver.RemoteSendingSharingEvent -> { if (_event.isSending()) { _call?.setSharingRenderView(screenShareView) } else { _call??.setSharingRenderView(null) } } } } } }) } else { val error = it.error } })
-
Start/stop sharing screen:
call.startSharing(CompletionHandler { if (it.isSuccessful){ // ... } }) call.stopSharing(CompletionHandler { if (it.isSuccessful){ // ... } })
-
Post a message
webex.messages.post(targetId, Message.draft(Message.Text.markdown("**Hello**", null, null)).addAttachments(localFile), CompletionHandler { result -> if (result.isSuccessful) { //message sent success } else { val error = result.error //message sent failed } })
-
Post a threaded message
webex.messages.post(targetId, Message.draft(Message.Text.markdown("**Hello**", null, null)) .addAttachments(localFile) .setParent(parentMessage), CompletionHandler { result -> if (result.isSuccessful) { //message sent success } else { val error = result.error //message sent failed } })
-
Set MessageObserver to receive messaging events
webex.messages.setMessageObserver(object : MessageObserver { override fun onEvent(event: MessageObserver.MessageEvent) { when (event) { is MessageObserver.MessageReceived -> { val message = event.getMessage() if (message?.getParentId() != null) { // Threaded message } } is MessageObserver.MessageDeleted -> { // message deleted } is MessageObserver.MessageFileThumbnailsUpdated -> { // thumbnails updated for files } is MessageObserver.MessageEdited -> { // message edited successfully. event.getMessage() returns the edited message. } } } })
-
Send Read Receipts
//Mark all existing messages in space as read webex.messages.markAsRead(spaceId) //Mark existing message before pointed message(include) in space as read webex.message.markAsRead(spaceId, messageId) //Mark existing message before pointed message(include) in space as read with a completion handler webex.message.markAsRead(spaceId, messageId, CompletionHandler { result -> if (result.isSuccessful) { // Success } else { // Failure } })
-
Get read status of a space
webex.spaces.getWithReadStatus(spaceId, CompletionHandler { result -> if (result.isSuccessful) { //show the data } else { //handle error } })
-
Set MembershipObserver to receive Membership events
webex.memberships.setMembershipObserver(object : MembershipObserver { override fun onEvent(event: MembershipObserver.MembershipEvent?) { when (event) { is MembershipObserver.MembershipCreated -> { //The event when a new membership has added to a space. ... } is MembershipObserver.MembershipUpdated -> { //The event when a membership moderator status changed ... } is MembershipObserver.MembershipDeleted -> { //The event when a membership has been removed from a space. ... } is MembershipObserver.MembershipMessageSeen -> { //The event when a user has sent a read receipt ... } } } })
-
Set SpaceObserver to receive Space events
webex.spaces.setSpaceObserver(object : SpaceObserver { override fun onEvent(event: SpaceObserver.SpaceEvent) { when (event) { is SpaceObserver.SpaceCallStarted -> { //The event when a space call was started ... } is SpaceObserver.SpaceCallEnded -> { //The event when a space call has ended ... } is SpaceObserver.SpaceCreated -> { //The event when a new space was created ... } is SpaceObserver.SpaceUpdated -> { //The event when a space was changed (usually a rename) ... } } } })
-
Get space meeting details
webex.spaces().getMeeting(spaceId, new CompletionHandler<SpaceMeeting>() { @Override public void onComplete(Result<SpaceMeeting> result) { if (result.isSuccessful()){ SpaceMeeting spaceMeeting = result.getData(); ... } } });
-
Get read status of a space
webex.spaces().getWithReadStatus(spaceId, new CompletionHandler<SpaceReadStatus>() { @Override public void onComplete(Result<SpaceReadStatus> result) { if (result.isSuccessful()){ SpaceReadStatus spaceReadStatus = result.getData(); ... } } });
-
Join password-protected meetings
mediaOption.setModerator(isModerator: Boolean) mediaOption.setPin(pin: String)
-
Change the composite video layout during a call
activeCall.setCompositedVideoLayout(layout: MediaOption.CompositedVideoLayout)
-
Specify how the remote video adjusts its content to be rendered in a view
activeCall.setRemoteVideoRenderMode(mode);
Use a completion handler to get the result of success or failure.
activeCall..setRemoteVideoRenderMode(mode, CompletionHandler { it.let { if (it.isSuccessful) { // callback returned success } else { // callback returned failure } } })
-
Change the max sending fps for video
webex.phone.setAdvancedSetting(AdvancedSetting.VideoMaxTxFPS(value: Int) as AdvancedSetting<*>)
-
Enable(disable) android.hardware.camera2
webex.phone.setAdvancedSetting(AdvancedSetting.VideoEnableCamera2(value: Boolean) as AdvancedSetting<*>)
-
Whether the app can continue video streaming when the app is in background
webex.phone.enableBackgroundStream(enable: Boolean)
-
Get a list of spaces that have an ongoing call
webex.spaces.listWithActiveCalls(CompletionHandler { result -> if (result.isSuccessful) { // callback returned success, result.data gives data if any } else { // callback returned failure } })
-
Check if the message mentioned everyone in space
message.isAllMentioned()
-
Get all people mentioned in the message
message.getMentions()
-
Change the max capture fps when screen sharing
webex.phone.setAdvancedSetting(AdvancedSetting.ShareMaxCaptureFPS(value: Int) as AdvancedSetting<*>)
-
Switch the audio play output mode during a call
activeCall.switchAudioOutput(mode: Call.AudioOutputMode);
-
Enable/Disable Background Noise Removal(BNR)
webex.phone.enableAudioBNR(enable: Boolean)
-
Set Background Noise Removal(BNR) mode
webex.phone.setAudioBNRMode(mode: Phone.AudioBRNMode)
-
Edit a message
webex.messages.edit(originalMessage, messageText, mentions, CompletionHandler { result -> if (result.isSuccessful) { // message edit success val editedMessage = result.data } else { // message edit failure } })
-
Enable/Disable background connection
webex.phone.enableBackgroundConnection(enable: Boolean)
-
Enable/Disable console logging
webex.enableConsoleLogger(enable: Boolean)
-
Set log level of logging
webex.setLogLevel(logLevel: LogLevel)
For multistream related API's see Multi Stream v3
For CUCM related API's see CUCM Usage Guide v3
The migration guide is meant to help developers port their code from SDK-v2 to SDK-v3. See Migration Guide For v2 to v3
The sample app demonstrates the common usage of SDK-v3. You can view the demo app Source Code
For a complete reference to all supported APIs, please visit Webex Android SDK API docs.
All contents are licensed under the Cisco EULA
See License for details.