mehcode / rn-splash-screen

A JavaScript-controlled splash-screen for React Native designed to be run directly after the native splash-screen.
MIT License
350 stars 95 forks source link

[Android] ReactInstanceEventListener not called after initial load #26

Closed ryankask closed 7 years ago

ryankask commented 7 years ago

I'm not too familiar with Android development but I've recorded a screencast that demonstrates the issue. Basically, the below callback is only firing when the app is first started, but not when relaunched. In addition, JS animations run very slowly. I did some profiling and it seems like it's because of the app's background image not being replaced in the callback (again, I'm not too familiar with Android dev and I may be reading the profiler output incorrectly).

I've tried several RN versions and it started happening in 0.33. This is the example app:

splash

        // After react is initialized; set our background color (override splash screen theme)
        getReactNativeHost().getReactInstanceManager().addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
            @Override
            public void onReactContextInitialized(ReactContext context) {
                // Hide the native splash screen
                Log.d("LPD", "called!");
                getWindow().getDecorView().setBackgroundColor(Color.WHITE);
            }
        });
freiserg commented 7 years ago

@mehcode It happens when use back android button.

mehcode commented 7 years ago

Fixed in v4.0.0; let me know if you still have problems. Usage changed a touch; check the example.

ryankask commented 7 years ago

Thanks! This appears to be working now.