# Android SDK
# Installation
The Android SDK will be available as an Android Archive (AAR) file that may be used as a dependency for an Android app module.
https://github.com/ATOS-VIRTUAL-CARE/vcs-realtime-sdk-android
# Requirements
- Android API level 23+
- JDK 8+
Built using:
- Gradle 6.7.1
- Kotlin 1.5.10
# Examples
The SDK resources can be accessed in the following package.
import net.atos.vcs.realtime.sdk*
# Initialize SDK
The Android Realtime SDK must first be initialized before it can be used. An optional custom logger may be specified by implmenting the LogWriter
interface. If a custom logger is not specified (as in this example) a default LogWriter
will be used that sends messages to logcat.
RealtimeSdk.initialize(applicationContext, null, LogWriter.LogLevel.DEBUG)
# Join Room
The SessionOptions are used to indicate the resources to be used when joining the room e.g., join a room with audio only by setting the video properties false
. In this example Test user
is joining the room using both audio and HD video.
val options = SessionOptions(
host = "https://<vcs-domain>/websocket/realtime/websocket",
audio = true,
video = true,
name = "Test User",
hdVideo = true)
RealtimeSdk.joinRoom(<token>, options, <RealtimeSdkListener>)
# Don't ask for camera/mic until other participant(s) joined
options.delayLocalStream = true
RealtimeSdk.joinRoom(<token>, options, <RealtimeSdkListener>)
# Display local mediaStream
val localView: MediaStreamVideoView = binding.localView
localView.init(RealtimeSdk.getRootEglContext(), null)
// Note: the SDK will handle mediaStream changes
room.localParticipant().setVideoView(WeakReference(localView))
# Display remote mediaStream
room.remoteParticipants().forEach { participant ->
inflater?.inflate(R.layout.remote_view, null)?.let { remoteView ->
remoteView.init(RealtimeSdk.getRootEglContext(), null)
// Add remoteView to you UI layout
. . .
participant.setVideoView(WeakReference(remoteView))
}
}
# Mute/unmute
// Toggle the microphone mute status
// Returns true if the client is muted
val isMuted = room.toggleMute()
# Switch camera
Switch between the front and back camera for local video.
room.switchCamera()
# Toggle video
room.toggleVideo()
# Toggle audio
toggleAudio
will add or remove an audio MediaStreamTrack in the local MediaStream. This is different from toggleMute
, which simply enables/disables the existing audio track.
room.toggleAudio()
# Leave the Room
room.leave()
# Logging
A custom logger that implements the LogWriter
interface can be passed to the SDK during initialization. If a custom logger is not specifed, as in the example below, a default logger will log to Logcat. The log level can also be specified; the default is INFO.
RealtimeSdk.initialize(applicationContext, null, LogWriter.LogLevel.DEBUG)