I am making an android app to open a file and send it back to a remote server. I know how to do this with a file hardcoded into the app but I want to make it so that it can search the phone's directory, choose a file then send it. I am wondering can this be done with an intent? Or is there any other approach that could be used?
Asked
Active
Viewed 27 times
1 Answers
0
Yes, you can do this with an Intent. You would use startActivityForResult() and specify an Intent that can launch a file picker. Now the actual Intent you use depends on which application(s) you expect will actually service this Intent for you. For example, ES File Explorer exports a custom PICK_FILE action that you can use to support a file picker. With any scenario where you rely on a third party application to provide a service, you'll want some sort of fallback in case no application can handle the Intent (such as linking to an app that implements the Intent in the Google Play store). A similar question may provide some additional Intents to try for a variety of different file choosers available.

Community
- 1
- 1

Michael Aaron Safyan
- 93,612
- 16
- 138
- 200