New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there any callback for android when ReactContext is created in MainAcitivity? #3887
Comments
I'm gettting the same issue when trying to track Android AppState. I've added a SO question here: http://stackoverflow.com/questions/35041962/react-native-android-reactcontext-returning-null Hope this is solvable! |
Hi @yychun1217 - I have created this solution for returning AppState (i.e. active or background) in Android today. Perhaps you can adapt it for your needs? |
You get the context in constructor of native modules. So there is really no reason you should need it in Closing this as tese kinds of questions are more suited towards stackoverflow. On another note, |
I think it's worth to reopen it, any kind of a such callback would be useful |
@pvllnspk What's your use case? |
f.e. send an initial event to js |
An initial event? Not sure I understand. If you're talking about Resume you can get that by listening for the host activity easily enough through a native module or a package like rn-device-activity If you're talking about really just wanting a way to show a loading screen while JS is loading you probably want a JS-controlled splash screen with something like rn-splash-screen |
I had the same problem with First, make your Activity/Fragment implement
When your
|
@lucas-tulio Why hooking to |
I checked that it is very strange that ReactInstanceManager.getCurrentReactContext in MainActivity would return null in onCreate and in onResume as well. I found that it should have been created in initializeReactContext() inside ReactInstanceManager, which is called when mReactRootView.initializeReactContext() is invoked.
Yet the context is still null, any hints?
The text was updated successfully, but these errors were encountered: