react-native: ReactContext: currentActivity is null when onActivityResult is called

I use addActivityEventListener to listen for the result of an Intent.

  1. when I start the Intent RN calls onHostPause and releases the reference mCurrentActivity in ReactContext.java.
  2. my onActivityResult fires, but there is no currentActivity set yet, because onHostResume is called afterwards.

0.29 / Android / Mac

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 27 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I hava the same issues. android version 0.36 when i used getCurrentActivity in ReactContextBaseJavaModule some times return null. I create ReactInstanceManager not in onCreate method,But in the onCreate after a period of time。 So there is no onHostResume method is called, passing the current activity to ReactContext. My solution is to create a ReactInstanceManager called after ReactInstanceManager.onHostResume.

@conover Did it fix your issues?

@fab1an, 0.32 becomes stable early next week and 0.33-rc is released. This issue has been there for a while so I don’t think we should rush and risk 0.32 stable and release it without a good 2 weeks of release-candidate testing. But thanks for caring and feel free to discuss more.

Ah yes, the problem there is the ReactInstanceManager gets destroyed when the Activity is destroyed. I might fix that soon anyway as part of a different thing I’m working on.

I can confirm this that I’ve run into this issue.

cc @foghina