Reputation: 105
I have implemented WebChromeClient
and from onPermissionRequest
I couldn't access to the Camera and Audio inside the app.
My Code iS
@Override
public void onPermissionRequest(PermissionRequest request) {
super.onPermissionRequest(request);
final String[] requestedResources = request.getResources();
for (String r : requestedResources) {
if ((r.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) || r.equals(PermissionRequest.RESOURCE_AUDIO_CAPTURE)) {
request.grant(new String[]{PermissionRequest.RESOURCE_VIDEO_CAPTURE,PermissionRequest.RESOURCE_AUDIO_CAPTURE});
break;
}
}
}
But I keep getting an exception and error as below
> W/System.err: **java.lang.IllegalStateException**: **Either grant() or
> deny() has been already called**. W/System.err: at
> org.chromium.android_webview.permission.AwPermissionRequest.b(chromium-TrichromeWebViewGoogle.aab-stable-1:3)
> at org.chromium.android_webview.permission.AwPermissionRequest.a(chromium-TrichromeWebViewGoogle.aab-stable-1:1)
> at xe.deny(chromium-TrichromeWebViewGoogle.aab-stable-1:1)
> at com.royalconx.MainActivity$MyChromeClient.onPermissionRequest(MainActivity.java:96)
> at org.chromium.android_webview.AwContents.onPermissionRequest(chromium-TrichromeWebViewGoogle.aab-stable-1:9)
> W/System.err: at android.os.MessageQueue.nativePollOnce(Native
> Method)
> at android.os.MessageQueue.next(MessageQueue.java:363)
> at android.os.Looper.loop(Looper.java:173)
> at android.app.ActivityThread.main(ActivityThread.java:8178)
> at java.lang.reflect.Method.invoke(Native Method)
> at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)
Upvotes: 2
Views: 2197
Reputation: 19223
if you have super
call in first line
super.onPermissionRequest(request)
then probably you can't "manually" call grant
or deny
again like you trying next in loop. move your code above super
call and be sure that super
won't be called for perms handled by yourself - make prepared PermissionRequest
without these, if not empty (any other perms requested) then call super
with this modified request
also be sure that whole app has proper perms acquired already
Upvotes: 3