0

SAF operations seem to use startActivityForResult to trigger the UI picker. This makes sense since when the user selects a document on the picker, the calling activity receives the uri via onActivityResult().

The problem is that I need to use SAF from a Service and startActivityForResult is Activity-specific. Is there another way to interact with SAF, one that can be used from an android service?

Daniel
  • 2,380
  • 29
  • 44
  • A service should only be working with a `Uri` that the user chose through the SAF activities. What is your use case for a service to try to work with storage providers in the absence of this? – CommonsWare Apr 30 '15 at 13:49
  • @CommonsWare: I have an android service talking with external hardware connected to the phone. The user can take an action on this external device, e.g. let's say pressing a button, to transfer a file from the device to the phone or vice versa. When the user presses the button I want the SAF picker to show up, then the user can select a document to transfer it to the external device. – Daniel Apr 30 '15 at 13:56
  • Then have your service start an activity that in turn uses the SAF normally. – CommonsWare Apr 30 '15 at 14:01
  • "Then have your service start an activity that in turn uses the SAF normally." -- At the moment that's my plan, but feels like an hack. – Daniel Apr 30 '15 at 14:06

0 Answers0