Reputation: 330
My android application opens the "document tree" selector to prompt read permission on an external storage full directory (as per android 10+ scoped storage rules).
Relative Code
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
startActivityForResult(intent, REQUEST_ID_PERMISSION);
Works fine for all tested versions and device variants. But, my crashlytics shows the below error ocuring a considerable number of times for some Samsung devices. (A20 - Android 9 | S10/10+ - Android 10 & 11 | Note20 - Android 11)
Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT_TREE flg=0x40 }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2071)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1717)
at android.app.Activity.startActivityForResult(Activity.java:5252)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
Any potential reason and solution for this problem, knowing that:
thank you.
Upvotes: 3
Views: 3620
Reputation: 23
I just ran into this exact same issue on my rooted OnePlus 6 with OxygenOS version 10.3.6 (Android 10), and the error message I got is pretty much identical to yours:
Error: Failed to choose folder: No activity found to handle intent { act=android.intent.action.OPEN_DOCUMENT_TREE flg=0xc3 (has extras) }
To resolve the error I had to manually install the com.android.documentsui
application, and I did so by following some of the steps detailed in this Android Stack Exchange answer: https://android.stackexchange.com/a/253276/404185
I had root on my phone, so happily I didn't have to bother with ADB. I simply opened a terminal emulator on my phone and executed the following two commands, one after the other:
su
cmd package install-existing com.android.documentsui
⚠️ Important: Remember to reboot your phone after executing either the ADB or terminal commands! |
---|
I am not 100% sure this code is applicable, but perhaps this fallback code can be used to gracefully handle this exception without requiring any user interaction nor the installation of any applications: https://github.com/signalapp/Signal-Android/commit/6e3751a0c5870f8dc4ad9d210ce08b153c3307bf
Upvotes: 0
Reputation: 113
Following solutions can fix this issue:
Upvotes: 0
Reputation: 481
Data point: I came across this discussion while searching the web for an explanation of a similar exception / crash reported by a user of an app of mine (on a Samsung S10). I pointed the user to this discussion, and sure enough, he had deactivated the Files app, and reactivating it solved the problem.
Upvotes: 1