|
The problem with using an Intent, is that the result of the Intent Activity is returned via the #onActivityResult method of the originating Activity. Even if we next Activities, the eventual result can still only propagate back to the downstream application thriugh the top level #onActivityResult method. We do not have the ability to directly influence the top level #onActivityResult method, and so cannot retrieve the token result ourselves.
I see two solutions to this problem:
-
Change the oauth2 API to be Intent based. Users' would start our activity to retreive a token, and they would receive their token via their #onActivityResult method. This would mostly involve sticking a facade in front of the current implementation, and would not be too honerous to implement.
-
Consider creating an Android Service to retrieve Oauth2 tokens. We would be able to start Activities and retrieve the result from within the Service. It's a little unclear however as to whether starting intents from a Service is good practice. We would however be able to maintain the same API style that we currently have.
|