Could a simple callback be an alternative? The user places the callback in the static field of your library, and your library will call this callback when needed. The simplest implementation may be as follows:
YourSdk.staticCallbackField=new OnData() { public void onData(Bundle data) {....}); MyIntent i = new MyIntent(); startActivity(i);
When the SDK shuts down, it calls a callback:
staticCallbackField.onData(data)
User activity will receive Bundle data in the callback instead of onActivityResult.
You should be aware of potential life cycle issues. For example, if an android recreates user activity in a background callback, you should recreate it.
Fedor
source share