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

Not working on Android, RN 0.29 #4

Closed avishayil closed 8 years ago

avishayil commented 8 years ago

Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.runnable)' on a null object reference

SplashScreen.java: 35, show function.

I'll try to make a PR compatible with RN 0.29.

mehcode commented 8 years ago

I just pushed a RN 0.29 compatible version last night. It's a huge hack and I haven't had time to document it. You need to store the package ref before the getPackages call and make sure to call setActivity on the onCreate in MainActivity.

If you have a better idea id love a PR.

avishayil commented 8 years ago

Take a look on my fork: https://github.com/avishayil/rn-splash-screen

It works fine, but the only caveat is when you resume an activity, the splash is not being shown on Android. If you kill the activity form the recent apps, it shows fine.

mehcode commented 8 years ago

@avishayil Why do you use postDelayed ?

avishayil commented 8 years ago

For safety. sort of like making sure that the activity exists before removing the splashscreen.

mehcode commented 8 years ago

The splash screen is removed from javascript where the Activity guaranteed to exist. I can see adding a configurable delay if you don't want to finetune where exactly its hidden.

mehcode commented 8 years ago

@avishayil Also it looks like your splash screen fork loads too late some times. There is a data race. Every like 4th run I get a small white blip.

Looking into a solution now as my earlier hack is awful.

mehcode commented 8 years ago

This should be resolved; check the revised documentation