I currently use LifecycleObserver
for notifying about events such as onStart
of my view. This is great for components as presenters or handlers, such as FacebookLoginHandler
that needs to register the callback once the view is ready. However, there are some situations, as the one I've mention, that I wanted my handler to handle the returned data of another activity.
Example:
When I choose to login with Facebook, it starts another activity and the return of it goes to view's onActivityResult
method. this makes me inject my FacebookLoginHandler
in the view, only to delegate the handling back to it. I wanted to use LifecycleObserver
to get notified of onActivityResult
and avoid having to couple my handler to the view only for delegating this event. Is there a way to do that?
I had exactly the same problem. I have "sign in with Facebook" functionality in my app and I want to move this functionality into separate class AuthManager
that implements LifecycleObserver
.
I have checked Lifecycle.Event
class that contains all the available lifecycle events. Looks like at the moment (android.arch version 1.1.0) there is no event for hading onActivityResult()
with LifecycleObserver
.
Opened an issue about this: https://github.com/googlesamples/android-architecture-components/issues/317