This Stackoverflow thread has some more options, like different mime types. Might be worth a try
ping @PaulAnnekov
I googled all the web and checked many SO questions. Immediately remove answers with /ACTION_GET_CONTENT/, because it's wrong action. Of course it can show you the contents, but when you will click on any file - activity will close and return you a link to selected file, because that's the purpose of ACTION_GET_CONTENT.
And ACTION_VIEW is not supported by most of the file managers + it's crashing. So I still think we should better integrate own file manager, because Android will tighten the screws more and more. Most sync software (Google Drive/Dropbox) have their own files view, so it won't damage UX.
Did you try the mime type */* or text/csv with ACTION_VIEW already? Integrated file manager would be okay if its not too much effort, but it would be much better if we could also support the user's chosen file manager.
I tried */* and text/csv with ACTION_VIEW.
*/* + ACTION_VIEW means - "show me intents that can view at least one mime type", so you get EVERYTHING (Contact viewers, Google Play Store, Music players, file explorers, emails apps...).
text/csv + ACTION_VIEW means "show me intents that can view files with csv mime type", so you get listed all text editors (ES Note Editor, FE Text Editor, FX Text Viewer, Totalcmd-Editor...).
This is a hard choice here:
Wouldn't it be possible to use */* + ACTION_VIEW the first time, and then remember the choice of the user in order to not bother them anymore with this long list of options??
@pchampin no, 1st option is "use embedded file manager", 2nd is "use intent that is supported by 1-2 file managers among dozens in the market + add ugly hack for Android 7".
Wouldn't it be possible to use / + ACTION_VIEW the first time, and then remember the choice of the user in order to not bother them anymore with this long list of options??
I don't know if you have an access to "use as default app..." checkbox in intents chooser, but I think - no.
goal:
since it seems there is no standard for this so whe should define the standard and ask the other file manager developers to implement this specific intent we define here.
my proposal: use this: https://stackoverflow.com/questions/17165972/android-how-to-open-a-specific-folder-via-intent-and-show-its-content-in-a-file
it already works with "EF File Explorer".
@contrapunctus-1 already made an attempt to ask file manager developers but without specifying how the intent should exactly look like.
note: total commander supports action=android.intent.action.VIEW with mime= * / * . i donot know if there is a more specific mime for total commander specific mime for this. There is also the proposal to use mime=resource/folder ( https://www.ghisler.ch/board/viewtopic.php?p=323853 )
@k3b yes, we can ask file manager devs to implement one of the API's, it requires a minimum of effort (but don't rely on them). Who will do this?
@k3b That's exactly the intent we're using, and it works with "ES File Explorer" (I assume you meant that).
Please go ahead and contact any developers of file managers. Here is the exact code we're using.
FTR, there is already an issue about that for the open-source Amaze file manager:
https://github.com/TeamAmaze/AmazeFileManager/issues/419
Hello everyone, I'm new to synthing.
I'm one of the developer of Amaze File Manager. We do support Intent.ACTION_VIEW but only for limited number of files (zip, rar, text/, xml/json/js, db/). As these are the extensions Amaze supports for viewing files. As for returning files, we support Intent.ACTION_GET_CONTENT for both files and folders.
Like I said, I'm new to synthing, I tried the app but couldn't find the option to opening a folder. One I did find was to browse for folder from 'Create folder' screen when I pressed on + icon at top right which popped up the inbuilt directory selection screen. Like I said, we support returning files/folders, hence this operation is already supported by Amaze.
So I'm not able to really understand the use case for this operation, please help me understand.
@vishal0071 This button will launch an intent to open the folder path in an external file manager:

@Nutomic so what is the option supposed to do? Simply open the file manager from that specific path?
Yes exactly
Very well. I've added support in Amaze for this form of intent.
I was made aware that there exists API to denote a directory mime type. Please check it here and make syncthing compatible to this so that I can also reflect to these changes.
That intent seems pretty bad. With intent.setData("file:/...) it doesn't bring up any app, not even ES Explorer which supports the resource/folder mime. Without that and only org.openintents.extra.ABSOLUTE_PATH, it shows every single app that can handle Intent.ACTION_VIEW. So using the mime type seems like the better option.
@Nutomic sorry my fault: only version with file:///path.... works. the version with file:/path.... does not.
I just checked it with the new IntentIntercept https://gitlab.com/fdroid/fdroiddata/merge_requests/2553 and ES Explorer.
I have just fixed my proposal in all threads where i added the proposal text.
This is the code I'm using, so Uri is something like file:///storage/emulated/0/DCIM:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.fromFile(new File(folder.path)));
intent.putExtra("org.openintents.extra.ABSOLUTE_PATH", folder.path);
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
getContext().startActivity(intent);
And its not working with ES Explorer (not sure which other apps I should test. Like I said, the resource/folder mime type at least works with ES Explorer.
@Nutomic Please use FileProvider for normal filesystem or DocumentProvider in case of SD Card/OTG to send data instead of using Uri#fromFile
I'll give you a modified apk of Amaze which shall work with this version. Meanwhile please provide me your build apk after making these changes so that I can also test on my end.
@vishal0071 Good point about FileProvider, I wasn't aware of that API. I still had to declare resource/folder mime type explicitly, otherwise ES Explorer wouldn't be shown in the intent chooser.
Edit: actually it doesn't work with ES Explorer. Either it doesn't show any folder contents, or it's loading forever.
Added support for opening resource/folder to Simple File Manager, for now only for "file://" uris. I will check the rest later.
@VishalNehra @k3b @pchampin @PaulAnnekov Hi together. I implemented a fallback mechanism in a debug build if resource/folder approach did not work to open the folder. Can you please check if it helps in cases a specific file explorer app was previously not supported? Link: https://build.syncthing.net/repository/download/SyncthingAndroid_Build/19963:id/debug/app-debug.apk
@Catfriend1 that's what I get. I have Xiaomi device with native File Explorer app.

I don't know why this issue was closed. I think the only way to close it is to use embedded file manager, because we won't ever support all variety of file managers, as there is no standard way to achieve what we want.
@PaulAnnekov Sorry, this seems to be hard way to find a compromise for all software out there. Let's sum up what we got now. If you click the open folder button, this will happen:
This is also the reason why all apps are shown to you on the screenshot. Looking with the "all" file type results in all apps being shown. I'd have liked to, but android won't let me filter out any app from there.
Built-In file managers afaik also don't have a common UI resource type they register. Some have, some won't. I'm pretty sorry it seems I only can help you if you figure out the URI type your built-in file manager listens to and put it maybe in between the checks of step 1) and 2) making sure the fallback is done correctly for the majority of users.
My point is that this issue should not be closed, because it's not resolved. And the only way to resolve it is to create embedded file manager.
Agreed. @Catfriend1 please don't close issues if people still have the problem.
Here is a good SO showing alternatives and on which devices they are expected to work: https://stackoverflow.com/questions/50072638/fileuriexposedexception-in-android/50102119#50102119
Sorry about the close, happened during the merge process.
@PaulAnnekov Would you mind helping me out by figuring out and posting your builtin file managers android package name here? Its sth like com.romname.filemanager.
@Catfriend1 com.mi.android.globalFileexplorer.
We already have some file managing activity, it's FolderPickerActivity (https://github.com/syncthing/syncthing-android/blob/master/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderPickerActivity.java). We can adjust it to support open/cut/paste/remove/share file actions. That should be enough.
@PaulAnnekov
I did some google research on com.mi.android.globalFileExplorer . Until now, I couldn't find any documented way to launch this file explorer app with a folder given it should initially open.
Only reference I found was here: https://github.com/gsantner/memetastic/blob/master/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java (line 454 // Mi File Explorer)
The Xiaomi app only seems to provide a folder chooser returning an URI with an absolute path which is not what what we need in this case.
I guess you're out of luck getting this fixed as I'm not happy to take time to reinvent the wheel and put a complete file manager code into syncthing-android which we have to maintain in the future. If someone else likes to do this, I would leave the decision if the code gets in or not to our maintainer.
I would have helped you if I could with a small adjustment as there are many file manager out in the wild. Is it really unacceptable for you to install another third party app that is supported by syncthing-android like ES File Explorer, OpenIntents File Explorer, Root Explorer ...?
@Catfriend1 I want every user to be able to browse synced folder from Syncthing. And I think the best way to do this is to implement it like other file clouds do - manage files directly in the app (Dropbox, Google Drive, ownCloud...). I don't force you to implement it or to support all external file managers.
We can treat this task as "Add support for all external file managers we can" and close it, if it's done. Then when somebody will be ready to do google drive-like file manager, he will open a new issue to discuss.
SideNote - I tried to implement opening syncthing folder using Samsung myFiles but it doesn't work. In case anyone reading this later has an idea, please give me a hint. Link to the branch code: https://github.com/syncthing/syncthing-android/compare/master...Catfriend1:supportSamsungFileManager
Most helpful comment
Added support for opening resource/folder to Simple File Manager, for now only for "file://" uris. I will check the rest later.