Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Folder - Intent chooser

Tags:

android

How to open a dialog that list all applications that can open a given folder?

I tried following code

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setData(Uri.fromFile(Environment.getExternalStorageDirectory()));
startActivity(Intent.createChooser(intent, "Open Folder"));

it says "No applications can perform this action."

My device has default File Explorer and AndroidZip applications (these apps can open a folder).

like image 685
dira Avatar asked Sep 06 '25 03:09

dira


2 Answers

it says "No applications can perform this action."

That is not surprising. You are not asking to open a "folder", as there is no such thing as a "folder" in the Intent system. You are trying to find out what applications can open a path with no file extension and no MIME type. There are no applications installed on your device that have an <intent-filter> on an activity that supports ACTION_GET_CONTENT on a path with no file extension and no MIME type.

You might try ACTION_VIEW. However, bear in mind that I would estimate that 90+% of Android devices will have nothing that deals with "folders" in this fashion, either.

like image 115
CommonsWare Avatar answered Sep 07 '25 22:09

CommonsWare


Try this here. Works for me.

public void openFolder()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
    + "/yourFolder/");
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));
}

See also here

like image 27
kaolick Avatar answered Sep 07 '25 21:09

kaolick



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!