processing-android icon indicating copy to clipboard operation
processing-android copied to clipboard

requestPermission() function is broken

Open codeanticode opened this issue 2 years ago • 6 comments

The following code:

color bckColor = #EA6411; 

void setup() {
  fullScreen();
  requestPermission("android.permission.READ_EXTERNAL_STORAGE", "handlePermission");
}

void draw() {
  background(bckColor);
}

void handlePermission(boolean granted) {
  if (granted) bckColor = #58EA11; 
}

should open a dialog for the user to grant read access to external storage, but no dialog is shown.

codeanticode avatar Jul 03 '22 04:07 codeanticode

Hi @codeanticode , what's your device Android API level ?

ranaaditya avatar Jul 03 '22 04:07 ranaaditya

This may be due to change in the storage permission in Android 10 and higher.

Check it out here

ranaaditya avatar Jul 03 '22 05:07 ranaaditya

As per the reference shared by @ranaaditya , It seems including android:requestLegacyExternalStorage="true" in AndroidManifest.xml can work. Also, It will require testing on newer as well as older Android platform devices. I'll look into it after the current emulator support task(will create a PR for this soon). @codeanticode

rupeshkumar22 avatar Jul 03 '22 07:07 rupeshkumar22

@ranaaditya I tested the code on a device running Android 12.

codeanticode avatar Jul 03 '22 11:07 codeanticode

@ranaaditya I tested the code on a device running Android 12.

@codeanticode Yeah, I think that's because of the latest Android API changes only.

I think not only Storage permission but also other permissions have been updated / changed so we need to work on them as well.

No worries we will update processing core will all updates from Android 8 onwards.

I will look into all the changes happened to permission system and other stuff as well and make separate issues for all :+1:

Thanks !

ranaaditya avatar Jul 03 '22 14:07 ranaaditya

I think this might be an invalid issue, I just realized that I forgot to add the READ_EXTERNAL_STORAGE permission in the manifest file. After doing that, it works.

codeanticode avatar Aug 01 '22 02:08 codeanticode