can you write a short snippet of using the android...
# ask-ai
c
can you write a short snippet of using the android sdk to start a session and end a session, that's all I want
t
Thanks for reaching out, Nathan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To help you get started and wrap up a session using the LiveKit Android SDK, here are some handy code snippets you can use: Starting a Session:
Copy code
val room = LiveKit.create(applicationContext)
lifecycleScope.launch {
    room.connect(url, token)
    room.localParticipant.setMicrophoneEnabled(true)
    room.localParticipant.setCameraEnabled(true)
}
Ending a Session:
Copy code
room.disconnect()
Just a quick heads-up: don’t forget to swap out
url
and
token
with your actual LiveKit server URL and authentication token. Also, make sure you’ve got the necessary permissions (
RECORD_AUDIO
,
CAMERA
) sorted before you start. If you need a hand with anything else, I’m here for you! Sources: sample-app-compose/src/main/java/io/livekit/android/composesample/CallActiv... | Android quickstart | LiveKit Docs
c
do you recommend using kotlin, or can I do this using regular java
t
Hey there! Just so you know, the LiveKit Android SDK is written in Kotlin, but don’t worry—it works perfectly with Java too. You can easily use the SDK in your Java-based Android apps without any hiccups. We’ve added handy compatibility features like
@JvmStatic
annotations to make sure everything integrates smoothly with your Java code. We do recommend Kotlin because of its modern features and great support for coroutines (which we use a lot in the SDK), but if you’re more comfortable with Java, you can totally get the same functionality there as well. Sources: livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Local...