Search code examples
androidreact-nativebackgroundrootvelo

My react native android application does not start from root component when I exit app and I reopen it


I am using react native navigation Wix V2. Splash screen is my root component. My home page data has been gotten in the splash screen from server and if it has been done successfully it navigates to my home page automatically. I exit from app in home screen as follow:

componentDidAppear() {
        handleAndroidBackButton(exitAlert);
    }

componentDidDisappear() {
        removeAndroidBackButtonHandler();
    }

The exitAlert function is:

const exitAlert = () => {

    Alert.alert(
        '',
        'Do you want to Exit?',
        [
            {text: 'Ask later', onPress: () => console.log('Ask me later pressed')},
            {
                text: 'No',
                onPress: () => console.log('Cancel Pressed'),
                style: 'cancel',
            },
            {text: 'Yes', onPress: () => BackHandler.exitApp()},
        ],
        {cancelable: false},
    )
};

The problem is when I exit from app with phone back button my app goes to background (That is correct) but when I open it again it does not start from my root component it shows my home screen. So if there is some changes in server side the web services in my splash screen does not call again and I cannot see the updates in my app.


Solution

  • I found my mistake, I had added android:launchMode="singleTop" this line of code to activity tag of manifest. I deleted it and now my app works correctly.