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. We'll use accompanist to make the process simple.
- Add permissions to
AndroidManifest.xml
Inside your AndroidManifest.xml, add the following inside the <manifest> tag:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
ℹ️ Note: The WAKE_LOCK permission is used to keep the device from sleeping during a video call. This ensures uninterrupted media streaming.
- Add dependencies and manifest permissions
First, add the Accompanist dependency to your build.gradle file:
- Implement permission handling in compose
With Accompanist, we use rememberMultiplePermissionsState. This allows the UI to automatically react when permissions are granted or denied. Create a new file VideoChatPermissionWrapper.kt as follows:
- Update
MainActivity.kt& define theinitializeSession()method as a placeholder for your video call setup"
Now, integrate this into your MainActivity. Simply call your VideoChatPermissionWrapper inside setContent.
- 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.