Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT_TREE cat=[android.intent.category.DEFAULT] } on kitkat android

Tags:

android

I'm developing application where I've to select a folder from external storage and then I've to get its path which I later pass to fileobserver. everything is working fine. I'm using this code to select directory:

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
                intent.addCategory(Intent.CATEGORY_DEFAULT);
                startActivityForResult(intent,RESULT_CODE);

and it gives me this interface: directory chooser

Problem: when I run app on KITKAT it gives me above mentioned exception. I've searched it over internet but could not figure out alternative for this. I just want to select directory and get its path on kikat.

like image 564
Faisal Avatar asked Oct 15 '25 20:10

Faisal


1 Answers

ACTION_OPEN_DOCUMENT_TREE was added in API 21 (Lollipop) - it does not exist on API 19 (Kitkat) devices and there is no equivalent for pre-API 21 devices.

You'll need to request the READ_EXTERNAL_STORAGE permission and build your own file browser from scratch if you want to let users select a folder on Kitkat devices.

like image 151
ianhanniballake Avatar answered Oct 18 '25 09:10

ianhanniballake



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!