zoontek / react-native-bootsplash

🚀 Show a splash screen during app startup. Hide it when you are ready.
MIT License
3.76k stars 258 forks source link

react-native run-android two applications appear? #22

Closed sharingjingang050241 closed 5 years ago

sharingjingang050241 commented 5 years ago

💻 My environment

🕵️‍♂️ Reproducing the issue

react-native run-android two applications appear? image

"react": "16.8.6",
"react-native": "0.60.5",
"react-native-bootsplash": "^1.0.0",

AndroidManifest.xml

<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:roundIcon="@mipmap/ic_launcher_round"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
  <!-- add the following lines -->
  <activity
    android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
    android:theme="@style/BootTheme"> <!-- apply the theme you created at step 3. -->
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
</application>

MainActivity.java


public class MainActivity extends ReactActivity {

    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "wywdrgapp";
    }

    @Override
    protected ReactActivityDelegate createReactActivityDelegate() {
        return new ReactActivityDelegate(this, getMainComponentName()) {
            @Override
            protected ReactRootView createRootView() {
                return new RNGestureHandlerEnabledRootView(MainActivity.this);
            }
        };
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        RNBootSplash.show(R.drawable.bootsplash, MainActivity.this); // <- display the "bootsplash" xml view over our MainActivity
    }
}
`

how to solve this. thanks 
sharingjingang050241 commented 5 years ago

emmmmmmmmmmm, This is my problem,sorry please close this .

albert-carreras commented 5 years ago

Can you explain what was wrong... Instead of just closing this? I'm facing the same issue

rodolphefauquez commented 5 years ago

@albert-carreras I had the problem too, but the solution is on the readme x).

In your manifest, you probably forgot to remove the default <intent-filter> lines from your original activity (.MainActivity)

Keep only the <intent-filter> of the 2nd activity ('com.zoontek.rnbootsplash.RNBootSplashActivity') :

<intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

So your manifest should be like something like that:

<application
    android:name=".MainApplication"
    ...
>

    <activity
      android:name=".MainActivity"
      android:exported="true"
      ...
      >
    </activity>

    <activity
      android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
      android:theme="@style/BootTheme">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>

    <!-- … -->
  </application>
kylanhurt commented 3 years ago

Thank you for the heads up. Fixed it for me as well. It seemed to only happen when I used the --logo-width=500 from the command line for some reason.