androidandroid-intentandroid-file

Android - Share intent with file manager as option


I want the following functionality:

In my application's internal storage I have a file and the user should be able to save it to another app (ex. Google Drive) OR save it to the phone's external storage by selecting a directory. Right now I can achieve this by two different methods, one displaying a chooser with the other apps, one opening a directory picker (ACTION_OPEN_DOCUMENT_TREE intent)

My question is that is it possible to have a chooser that would contain all the app's that could save the file (ex. Google Drive, OneDrive, etc.), INCLUDING the phone's file manager so if the user selects that option he can choose a directory?

Right now the ACTION_SEND intent doesn't contain the file manager.


Solution

  • Intent.createChooser() can take a list of intents.

    Have a look at

    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentsList.toArray(new Parcelable[]{}));