processing / processing-android

Processing mode and core library to create Android apps with Processing
http://android.processing.org
779 stars 293 forks source link

requestPermission() function is broken #699

Closed codeanticode closed 2 years ago

codeanticode commented 2 years ago

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.

ranaaditya commented 2 years ago

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

ranaaditya commented 2 years ago

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

Check it out here

rupeshkumar22 commented 2 years ago

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

codeanticode commented 2 years ago

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

ranaaditya commented 2 years ago

@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 !

codeanticode commented 2 years ago

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.