# Image Loader / Explorer Dialog Box (Android 10 update at bottom)

**URL:** <https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849>\
**Category:** Processing for Android\
**Created:** [November 26, 2019, 10:11pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849 "2019-11-26T22:11:23Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 8:10pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/21 "2020-10-25T20:10:48Z")

</div>

You should just be able to use my updated code, along with your original code. No need for the pimage to bitmap conversion. I have trimmed the permissions code to its bare essentials and it works with your code. Just set it to write\_external\_storage in caps, and assign the permission fail message you want.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 8:42pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/22 "2020-10-25T20:42:13Z")

</div>

> [@paulgoux](#):
>
> You should just be able to use my updated code,

Yes, but only if I set my SDK target to 20. I want to be able to use all the other features provided by the newer versions. Your permissions class works OK

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:09pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/23 "2020-10-25T21:09:38Z")

</div>

I tested the new code using the standard processing ide, sorry forgot to precise this. So no need to downgrade to android 20 apk just build it straight from the PC environment.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:13pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/24 "2020-10-25T21:13:45Z")

</div>

> [@paulgoux](#):
>
> So no need to downgrade to android 20 apk

That’s odd. I only work with APDE, and it doesn’t except the original + your permissions class without setting to SDK 20.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:16pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/25 "2020-10-25T21:16:00Z")

</div>

Ok let me test further, can you check from your machine if it works from your pc (if android mode is installed).

full code

```auto
import android.net.Uri;
import android.database.Cursor;
import android.content.Intent;
import android.provider.MediaStore;
import android.app.Activity;
import android.content.Context;
import android.os.Environment;
import android.Manifest;
//import android.appcompat.app.AppCompatActivity;
import java.io.*;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.FileInputStream;
import java.awt.FlowLayout;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import android.graphics.*;
private static final int REQUEST_EXTERNAL_STORAGE = 1;
Activity act;
Context mC;
PImage img;
boolean img_loaded;
String s;
Permission eStorage;

void settings() {
  fullScreen();
}

void setup() {
  //verifyStoragePermissions();
  s = Environment.getExternalStorageDirectory().getAbsolutePath();
  eStorage = new Permission(this,"WRITE_EXTERNAL_STORAGE");
  println(s);
  background(#F9C454);
  fill(#4A3A16);
  textSize(38);
  textAlign(CENTER);
  text("Click on screen", width/2, height/3);
  act = this.getActivity();
  mC= act.getApplicationContext();
}

void draw() {
  if (img_loaded&&img!=null) image(img, 0, 0);
}

void mousePressed() {  
  searchImage();
}

public void searchImage() {
  Intent intent = new Intent(Intent.ACTION_PICK, 
    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  intent.setType("image/*");
  //Activity a = 
  act.startActivityForResult(intent, 1);
}

@Override 
  void onActivityResult(int requestCode, int resultCode, Intent data) {

  super.onActivityResult(requestCode, resultCode, data);
  if (requestCode == 1) {
    if (resultCode == Activity.RESULT_OK) {
      if (data != null) {
        Uri selectedImage = data.getData();
        String[] filePathColumn = { MediaStore.Images.Media.DATA };
        Cursor cursor = mC.getContentResolver().query(selectedImage, 
          filePathColumn, null, null, null);
        cursor.moveToFirst();
        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String imgDecodableString = cursor.getString(columnIndex);
        cursor.close();
        println( imgDecodableString);
        img = loadImage( imgDecodableString);
        img_loaded = true;
      } else {
        println("Cancelled");
      }
    }
  }
};

public class Permission{
  
  PApplet parent;
  
  public boolean requestedPortraitImage = false;

  public Permission(PApplet pParent,String permissionName) {
    parent = pParent;
    parent.requestPermission("android.permission."+permissionName, "onPermissionResult", this);
  };

  public void onPermissionResult(boolean granted) {
    if (!granted) {
      PApplet.println("User did not grant camera permission. Camera is disabled.");
    }
  };

};

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:18pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/26 "2020-10-25T21:18:14Z")

</div>

> [@paulgoux](#):
>
> can you check from your machine if it works from your pc

Sorry, I’ve usb connection problems, and never got the virtual device working.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:23pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/27 "2020-10-25T21:23:55Z")

</div>

no worries, ive just attempted the code and it also works from apde you just need to set sketch permissions in the properties.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:27pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/28 "2020-10-25T21:27:45Z")

</div>

> [@paulgoux](#):
>
> you just need to set sketch permissions in the properties.

Sure, I know, I always do, but it doesn’t run on my phone.  
Did you try my code? Setting to target 29?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:30pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/29 "2020-10-25T21:30:27Z")

</div>

Just to confirm are you setting this permission

 ![Screenshot_20201025_212837_com.calsignlabs.apde](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/a/a6d60eeb5b7ecfdb2c0327dd12d9b65de9234baf.jpeg)

Gives me the following screen

 ![Screenshot_20201025_213041_com.google.android.permissioncontroller](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f4c6006d176956209309db1ec08a5e88213be571.jpeg)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:32pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/30 "2020-10-25T21:32:00Z")

</div>

Of course. I am using APDE for 2,5 years now.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:32pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/31 "2020-10-25T21:32:30Z")

</div>

Im. Just super confused…

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:36pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/32 "2020-10-25T21:36:57Z")

</div>

What version of android are you using, just seeing if we can isolate the problem. I’m on emu 10 for huawei which i think is equivalent to android 10.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:39pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/33 "2020-10-25T21:39:52Z")

</div>

> [@paulgoux](#):
>
> What version of android are you using

Real Android 10 device.  
Did you desinstall the previous app, for a clean restart?  
Are you using APDE “app mode” not “preview”?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:40pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/34 "2020-10-25T21:40:48Z")

</div>

Yeah in app mode not preview

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:47pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/35 "2020-10-25T21:47:32Z")

</div>

> [@noel](#):
>
> Did you try my code? Setting to target 29?

Did you?..

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:49pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/36 "2020-10-25T21:49:48Z")

</div>

OK, so in preview mode it does not work… Not sure why, in app mode it works even in apk 29. Not sure how to get preview mode working, does app mode also not work for you?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:50pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/37 "2020-10-25T21:50:44Z")

</div>

> [@paulgoux](#):
>
> does app mode also not work for you?

Nope…

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 9:52pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/38 "2020-10-25T21:52:48Z")

</div>

Does it at least run but fails when you load a pic or does it not run at all?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2020, 9:53pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/39 "2020-10-25T21:53:47Z")

</div>

Crashes as soon as I choose picture.

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [October 25, 2020, 10:11pm UTC](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849/40 "2020-10-25T22:11:27Z")

</div>

Really sorry no idea why I wrote 29 that was supposed to be on 26, 29 fails on my phone too.

Ps I think I tested with 29 after building once with 26 and that works, but after a clean install 29 fails.

[Previous page](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849.md?page=1)

[Next page](https://discourse.processing.org/t/image-loader-explorer-dialog-box-android-10-update-at-bottom/15849.md?page=3)
