React Native Android Splash Screen

I am trying to create a splash screen for an Android RN application. I followed the steps described here: https://www.bignerdranch.com/blog/splash-screens-the-right-way/

Unfortunately, when I try to launch my application, the assembly will be successful, but the application will fail, saying:

Error type 3 Error: Activity class {com.needlios/com.needlios.MainActivity} does not exist. 

Does anyone know where this could have come from?

I have the following code:

SplashScreen.java

 package com.needlios; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } } 

MainActivity.java

 package com.needlios; import com.facebook.react.ReactActivity; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; import java.util.Arrays; import java.util.List; 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 "NeedlIOS"; } /** * Returns whether dev mode should be enabled. * This enables eg the dev menu. */ @Override protected boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } /** * A list of packages used by the app. If the app uses additional views * or modules besides the default ones, add more packages here. */ @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), ); } } 

AndroidManifest.xml

 <activity android:name=".SplashActivity" android:label="@string/app_name" android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 
+5
source share
3 answers

Good, good that he is working now. I just changed android:name to android:name=".MainActivity" in AndroidManifest.xml

It works, but I don’t understand why it shows a splash screen, though ...

+3
source

Just to share how I got this job too.

The change

Android: name

to

android: name = ". MainActivity" in AndroidManifest.xml

works because the whole background has been changed to Splashscreen. This may not be a very good solution, as if backgroundColor was removed from any screen; This screen saver background will be displayed. In the end, this will lead to some unwanted displays when you need to integrate with some camera features. :(

Most codes are based on this link when only splash activity is removed. If someone is looking, add the values ​​/colors.xml and drawable / backgroundsplash.xml.

0
source

You cannot create a screensaver inside the ract-native script, you need to go to the original implementation. To make a simple screensaver, you need to install "android: windowBackground" on the theme that you use as your main activity. Thus, they will be displayed to the user until your opinion on the reaction is fully loaded. Here's an article on how to do this.

-3
source

Source: https://habr.com/ru/post/1242772/


All Articles