Meeting instance
In order to join/interact with the Meeting you need to create an instance
val eyesonMeeting = EyesonMeeting(
application = getApplication()
)
Join a meeting
Can either be done via accessKey
or guestToken
.
audioOnly
no video will be sent/received
local
/remove
are the respective VideoRenderer. Can be left null at start and set at a later time. Video will be sent/received regardless.
screenShareInfo
If provided join the meeting with active screen share (your local video won't be visible until the screen share is stopped) See Screen share for further information.
The Android OS could suspend your app execution as soon as it is no longer visible to the user. In order to prevent this, you must start a foreground service.
See Background handling for further information.
Join meeting with accessKey
eyesonMeeting.join(
accessKey = accessKey,
frontCamera = true,
audioOnly = false,
local = localVideoRenderer,
remote = remoteVideoRenderer,
eventListener = eyesonEventListener,
microphoneEnabledOnStart = true,
videoEnabledOnStart = true,
screenShareInfo = null
)
Join meeting with guestToken
eyesonMeeting.joinAsGuest(
guestToken = guestToken,
name = "My name in the meeting",
id = null, // optional
avatar = null, // optional public URL
frontCamera = true,
audioOnly = false,
local = localVideoRenderer,
remote = remoteVideoRenderer,
eventListener = eyesonEventListener,
microphoneEnabledOnStart = true,
videoEnabledOnStart = true,
screenShareInfo = null
)
Background handling
To prevent the OS from suspending the execution of your app, you need to start a foreground service.
Manifest
Add the following permissions and service to your manifest
<!-- For API >= 33 -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- For API >= 34 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<application
...
<service
android:name=".service.MeetingActiveService"
android:exported="false"
android:foregroundServiceType="camera|microphone" />
</application>
Service
Create a foreground service to maintain your application's execution during video meetings. You can implement this using the example below or customize it to suit your application's needs. This service helps prevent the Android system from terminating your video meeting process when the app is in the background.
camera and microphone are while-in-use permissions. Be aware of that when starting your foreground service!
See Foreground services and Restrictions on starting foreground services for detailed information
class MeetingActiveService : Service() {
override fun onBind(intent: Intent?): IBinder? {
// Not a bound service
return null
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
createNotificationChannel()
val foregroundServiceType = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
} else {
0
}
ServiceCompat.startForeground(this, 1, generateInCallNotification(this), foregroundServiceType)
return START_STICKY
}
override fun onTaskRemoved(rootIntent: Intent?) {
stopSelf()
}
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
IN_CALL_CHANNEL_ID,
IN_CALL_CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT
)
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
manager.createNotificationChannel(channel)
}
}
private fun generateInCallNotification(context: Context): Notification {
val pendingIntent =
PendingIntent.getActivity(
context, 0,
Intent(context, MainActivity::class.java),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_ONE_SHOT
)
return NotificationCompat.Builder(context, IN_CALL_CHANNEL_ID)
.setOngoing(true)
.setSilent(true)
.setContentText(context.getText(R.string.click_to_resume))
.setContentTitle(context.getText(R.string.active_call))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setSmallIcon(R.drawable.video_call_24)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build()
}
companion object {
const val IN_CALL_CHANNEL_ID = "17"
const val IN_CALL_CHANNEL_NAME = "In call"
}
}
Start foreground service
You can start the service as soon as you have joined the meeting, or at the latest when your application transitions to the background. This ensures continuous operation of the video call even when the app is not in the foreground.
val intent = Intent(context, MeetingActiveService::class.java)
ContextCompat.startForegroundService(context, intent)
Stop foreground service
When the meeting has ended or your application returns to the foreground, you should stop the foreground service to free up system resources and remove the persistent notification. Implement this when users leave the meeting or when your app regains focus.
val intent = Intent(context, MeetingActiveService::class.java)
context.stopService(intent)