Open Folder - Intent Chooser
Solution 1:
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.
Solution 2:
Try this here. Works for me.
publicvoidopenFolder()
{
Intentintent=newIntent(Intent.ACTION_GET_CONTENT);
Uriuri= Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/yourFolder/");
intent.setDataAndType(uri, "*/*");
startActivity(Intent.createChooser(intent, "Open folder"));
}
See also here
Solution 3:
Because files that are directories don't seem to have a standard mime type, I coded my file explorer to filter for intents without a mime type. Just set the data to your folder's Uri.
Intentintent=newIntent(Intent.ACTION_VIEW);
Uriuri= Uri.parse("file:///sdcard/MyFolder");
intent.setData(uri);
startActivity(intent);
This intent will launch following app:
http://play.google.com/store/apps/details?id=com.organicsystemsllc.thumbdrive
I find this also works well to open either file or folder depending on extension. The file extension and mime type for folder's uri ends up being null in the code snippet below. This still works to match activities that filter for scheme “file” but no specific mime type, i.e. Thumb Drive. Note that this approach will not find activities that filter for all file mime types when uri is a directory.
//Get file extension and mime typeUriselectedUri= Uri.fromFile(file.getAbsoluteFile());
StringfileExtension= MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString());
StringmimeType= MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
//Start Activity to view the selected fileIntentintent=newIntent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, mimeType);
startActivity(Intent.createChooser(intent, "Open File..."));
Solution 4:
It works:
UriselectedUri= Uri.parse(Environment.getExternalStorageDirectory() + "/myFolder/");
Intentintent=newIntent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
startActivity(intent);
Have a nice codding :)
Solution 5:
Unfortunately, like @CommonsWare said, there doesnt exist the standard definition of "File Explorer" in stock Android systems (unless you install 3rd party "File Explorer")..
That's why "resource/folder"
mime-type doesnt work by default..
Maximum I've found, was this: https://stackoverflow.com/a/41614535/2377343
Post a Comment for "Open Folder - Intent Chooser"