Requesting permissions
Because our app uses audio and video from the user's device, we’ll need to add some code to request audio and video permissions.
- Add permissions to
AndroidManifest.xml
Inside your AndroidManifest.xml, add the following inside the <manifest> tag:
ℹ️ Note: The WAKE_LOCK permission is used to keep the device from sleeping during a video call. This ensures uninterrupted media streaming.
- Request runtime permissions in your
MainActivity.kt
We’ll now update your MainActivity to request permissions at runtime using. At the top of your MainActivity.kt, define the permissions your app needs and a request code constant:
- Define
requestPermissionLauncherin in yourMainActivity.kt. It will handle the permission response for us.
- Check for permissions in
onCreate()
In your onCreate() method, check whether all required permissions have been granted. If they have, proceed to initialize the video session. Otherwise, request the permissions.
- Implement the helper method
hasPermissions()
Add this helper method to check if all required permissions are already granted:
- Complete
MainActivity.ktby creating a session placeholder
Define the initializeSession() method as a placeholder for your video call setup. Below is the complete MainActivity.kt with everything so far:
- Next Steps
Once permissions are granted, the initializeSession() function will be triggered. In the next steps of the tutorial, you'll implement the logic to connect to a Vonage Video API session.
Basic video chat
Learn the basic concepts of the Vonage Video API platform, including how users can communicate through video, voice, and messaging. Explore a basic Vonage Video API flow.