Hello everybody,
I hope you're all doing well while following your local safety guidelines. Many may have this issue as well, I'm not sure, but I was wondering if there's a way to add permissions once and that's it. For example...
interface PermissionInterface {
public void permissionGranted(Runnable task);
}
public class LocalInterface implements PermissionInterface {
public LocalInterface() {}
@Override
public void permissionGranted(Runnable task) {
READ_EXTERNAL_STORAGE = true;
new Thread(task).start();
}
}
public void AskForReadPermission(final Runnable task, final String taskName) {
form.askPermission("android.permission.READ_EXTERNAL_STORAGE", new PermissionResultHandler() {
@Override
public void HandlePermissionResponse(String permission, boolean granted) {
if (granted) {
PermissionInterface permissionInterface = new LocalInterface();
permissionInterface.permissionGranted(task);
} else {
form.dispatchPermissionDeniedEvent(me, taskName, "android.permission.READ_EXTERNAL_STORAGE");
}
}
});
return;
}
From the block, I am using...
// Located inside of `CensoredClassName extends AndroidNonvisibleComponent` before `public CensoredClassName() {}`
... private ComponentContainer container;
... private CensoredClassName me = this;
// ---
@SimpleFunction()
public String CensoredMethodName(final String param1, final String param2) {
if (!READ_EXTERNAL_STORAGE) {
// Permission not granted
final Runnable r = new Runnable() {
@Override
public void run() {
me.CensoredMethodName(param1, param2);
}
};
AskForReadPermission(r, "CensoredMethodName");
} else {
// READ_EXTERNAL_STORAGE is granted
return "a result if permission granted";
}
// Nothing is being returned from above, permission denied
return "";
}
It asks for the permission, but after granting the permission, I have to click on my demo button a second time to get the new result or reload my test app and click the button once if the permission is granted already. Is there any way to fix this? Or am I doing something wrong?