Search code examples
javaandroidandroid-intentandroid-10.0filechooser

Open with dialog appears after choosing a file on Android 10


After upgrading my phone(Redmi 7a pie) to android 10 sometimes open with dialog appears when choosing a file with file chooser

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
if (intent.resolveActivity(getPackageManager()) != null) {
   startActivityForResult(Intent.createChooser(intent,null), 1);
}`

I have also tried with "ACTION_OPEN_DOCUMENT"

Do you have any idea how to fix this?

Thanks enter image description here

Edit: A solution from @Rinkal Patel with "ACTION_PICK" enter image description here Very limited


Solution

  • Intent intent = new Intent(Intent.ACTION_PICK);
    intent.setType("image/*");
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(Intent.createChooser(intent,null), 1);
    }