skip to Main Content

I have seen a lot of solutions using the react-native-splash-screen library for react native projects.

Is there any way to implement splash screen in android(java) for a react native project without using the react-native-splash-screen library or without any external libraries?

2

Answers


  1. You can do that by creating a new java class with extends AppCompatActivity class. Then you need to modify the manifest XML file also by including this new activity. This Splash screen code need to be inside of onCreate method.

    Login or Signup to reply.
  2. You can use setTimeout to display your Splash screen and then navigate to either Login or Homescreen as per your APP Navigation Routes. For Example`

    class Splash extends Component{                  
      componentDidMount = () => {
    
        this._init()
    }
    
    _init = async () => {
        const userPrefs = await getUserPref();
    
        if (userPrefs !== null) {
    
            setTimeout(() => {
                
                    this.props.navigation.replace('Home')
              
            }, 1000);
        } else {
            setTimeout(() => {
                this.props.navigation.replace('Start')
    
            }, 1000);
        }
    }
    
    
    render() {
        return (
            <View style={styles.parent}>
    
                <Image
                    source={Images.logo}
                    style={styles.logo}
                    resizeMode='contain'
                />
                
            </View>
        )
    }}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search