Hello,
I am using GVR (with SDKs None and Cardboard) in an app where there is also the need for a camera access.
Even if there is the needed permissions in the Android manifest, the application doesn't request the needed permissions, therefore the camera fails to open.
I have tested to ask for permissions with GvrPermissionsRequester but the application crashes when I call the RequestPermissions method.
How can I avoid this issue ?
Thanks!
Hello fabien-lg, can you attach a log from your crash?
Hello,
Here it is :
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.vr.ndk.base.DaydreamApi.launchInVr(android.content.Intent)' on a null object reference
at com.google.gvr.permissionsupport.PermissionsFragment$1.run(PermissionsFragment.java:141)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5418)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Hi Fabien,
Is your app a Cardboard app? I believe the PermissionsFragment will only work with Daydream VR apps. This could explain why it's crashing in launchInVr.
Bill
Hello,
Yes indeed, it is a Cardboard application.
So, if the PermissionsFragment doesn't work in Cardboard, how can we request the camera permissions?
Thanks,
For Cardboard, you can request the permission at the start before the user puts the phone in the Cardboard viewer.
In Cardboard, you request camera permissions just like any other Android app.
Hello,
Could you instruct on how to do that in Unity?
Because even if the permission is set in the manifest, the SDK seems to ignore it and the permission dialog is never shown.
Thanks
Check to see if this is in your manifest:
meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true"
It causes Unity to skip asking for permissions when the game starts. This is discussed in the Unity manual: https://docs.unity3d.com/Manual/android-manifest.html
Thanks @bbilodeau ,
This 芦skip禄 line was actually there, but without being in any of my manifests.
So I added
<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false"/>
And it worked. I suspect that some Plugin or Unity itself is adding that when VR聽is enabled.
Maybe this is a question for Unity then...
Thanks for your help!