That's not what I was looking for.
Anyway @ewpatton, this is my new code and it works...
interface PermissionListener {
public void onPermissionGranted();
}
public void AskForReadPermission(final PermissionListener permissionListener) {
if (!READ_EXTERNAL_STORAGE) {
form.askPermission("android.permission.READ_EXTERNAL_STORAGE", new PermissionResultHandler() {
@Override
public void HandlePermissionResponse(String permission, boolean granted) {
if (granted) {
READ_EXTERNAL_STORAGE = true;
if (permissionListener != null) {
permissionListener.onPermissionGranted();
}
} else {
form.dispatchPermissionDeniedEvent(me, "$AskForReadPermission", "android.permission.READ_EXTERNAL_STORAGE");
}
}
});
} else {
if (permissionListener != null) {
permissionListener.onPermissionGranted();
}
}
return;
}
@SimpleEvent()
public void EventName(String param1, String param2, String param3, String param4) {
EventDispatcher.dispatchEvent(this, "EventName", param1, param2, param3, param4);
}
// Example function using new method, any function that does not require
// a permission is used as a `return` statement by it's respective type
// @SimpleFunction()
// public returnType CensoredMethodName2() {
// // Does not require permission, below you can see a method showing the difference
// return true || "string" || 0;
// }
@SimpleFunction()
public void CensoredMethodName(final String param1, final String param2) {
if (READ_EXTERNAL_STORAGE) {
// Permission granted
EventName("CensoredMethodName", param1, param2, String.valueOf(result));
} else {
// READ_EXTERNAL_STORAGE not granted
AskForReadPermission(new PermissionListener() {
@Override
public void onPermissionGranted() {
// Loop back around to check if READ_EXTERNAL_STORAGE was granted
// and send a result to the event
me.CensoredMethodName(param1, param2);
}
});
}
}