Skip to content

Commit 9d4c4b0

Browse files
committed
call request handler method even if the app already has the permission
1 parent 22bc268 commit 9d4c4b0

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

core/src/processing/core/PApplet.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,27 @@ public void requestPermission(String permission) {
599599

600600

601601
public void requestPermission(String permission, String callback) {
602-
if (!hasPermission(permission)) {
603-
Method handleMethod = null;
604-
try {
605-
Class<?> callbackClass = this.getClass();
606-
handleMethod = callbackClass.getMethod(callback, new Class[] { boolean.class });
607-
} catch (NoSuchMethodException nsme) {
608-
System.err.println(callback + "() could not be found");
609-
}
610-
if (handleMethod != null) {
602+
Method handleMethod = null;
603+
try {
604+
Class<?> callbackClass = this.getClass();
605+
handleMethod = callbackClass.getMethod(callback, new Class[] { boolean.class });
606+
} catch (NoSuchMethodException nsme) {
607+
System.err.println(callback + "() could not be found");
608+
}
609+
if (handleMethod != null) {
610+
if (hasPermission(permission)) {
611+
// If the app already has permission, still call the handle method as it
612+
// may be doing some initialization
613+
try {
614+
handleMethod.invoke(this, new Object[] { true });
615+
} catch (IllegalAccessException e) {
616+
e.printStackTrace();
617+
} catch (IllegalArgumentException e) {
618+
e.printStackTrace();
619+
} catch (InvocationTargetException e) {
620+
e.printStackTrace();
621+
}
622+
} else {
611623
permissionMethods.put(permission, handleMethod);
612624
// Accumulating permissions so they requested all at once at the end
613625
// of draw.

0 commit comments

Comments
 (0)