Android Permissions
In this guide we’ll show you how to set up Android permissions required to fully use the Odin Plugin in Unreal. These settings will also work for your Meta Quest VR projects.
By David Liebemann at SciCode Studio.
Check and request permissions
We’ll make sure to check our permissions before we actually initialize Odin. The implementation gets called right after BeginPlay
in the Custom Event ConnectToRoom
that only replicates on the owning client. This ensures that we don’t accidentally request permissions or try to initialize Odin on our server.
The steps for checking and requesting permissions now are:
- We’ll use
Get Platform Name
to check our current platform - if we’re not on theAndroid
platform, we can instantly go toInit Odin
, which contains our logic for joining an Odin room. Otherwise we’ll continue with step 2.
The platform name will also be Android
on the Meta Quest.
A call to
Check Android Permission
with the inputandroid.permission.RECORD_AUDIO
will tell us if the user already supplied the microphone permission. If yes, we can jump toInit Odin
again, otherwise we’ll need to request the permission.Before requesting, we’ll need to add a
Delay
node with an arbitrary duration. This is due to an Unreal issue, that crashes the application if permissions are requested too early. After the delay, we’ll callRequest Android Permission
with an array that has anandroid.permission.RECORD_AUDIO
entry. The function returns a delegate that allows us to connect to a callback event once the permission was granted or declined.In the callback, we’ll simply iterate over the result arrays and check for our
android.permission.RECORD_AUDIO
permission. If the permission was granted successfully, we’ll continue toInit Odin
.
The complete blueprint should now look something like this:
Add permissions to manifest
In addition to setting up the request in blueprint, we’ll also need to add the record audio permission in the Android Manifest file. We’ll do this by opening up the project settings, navigating to Android > Advanced APK Packaging
and adding the value android.permission.RECORD_AUDIO
to the Extra Permissions
array.
What’s next?
We’ve shown you the minimal version for checking and requesting microphone permissions for the Android and Meta Quest platform in Unreal.
If a player refuses to give the microphone permission, we currently simply refuse to initialize Odin. In a more sophisticated app we could still allow the player to listen in to the Voice Chat, while not being able to transmit. If the player changes their mind, we could provide a UI element, which reruns the request permissions logic and initializes microphone capturing, if the permission is then granted.
You could take a look at our Sample Project, which includes a minimal multiplayer setup and a detailed demonstration of the Android Permission setup. For an overview of what these samples offer, visit our introduction to the Odin Minimal Samples projects. Ready to dive in? Access the full source code on our GitHub page:
For even more information on Unreal with Odin Voice Chat, check out our Discord and take a look at the following guides we’ve prepared for you: