Despite similar question was asked, I have differnet situation:
My app consists mostly of a background Service
. I want to start external activities and get results back.
I see several options:
Create dummy
Activity
and keep reference to it for using itsstartActivityForResult
. This consumes quite a lot of memory, as we know.Use
Broadcast Intents
instead of Android's results infrastructure: ask client activities to broadcast their results before closing. This kind of breaks the idea and not so performance-efficient.Use
Instrumentation
directly - try to copy code from startActivityForResult into my Service.Use Service interfaces - serialize and add
AIDL
connection to the Intent for starting an Activity. In this case Activity should call Service directly instead of providing result.
The third approach feels closer to Android for me, but I'm not sure if it's possible to do - Service does not have its Instrumentation, and default implementation seems to always return null.
Maybe you have any other ideas?