Android应用中在React Native应用之前出现虚假闪屏问题。

huangapple go评论72阅读模式
英文:

Issue with Fake Splash Coming in Android before Custom Splash In React Native App

问题

我已在我的React Native应用程序中创建了一个自定义闪屏,它在所有iOS设备上都能正常工作,甚至在一些Android设备上也能正常工作。

因此,在Android设备上出现问题的原因是,当我通过点击应用程序图标首次启动应用程序时,它首先显示带有应用程序图标的黑屏作为虚拟闪屏,然后才显示自定义闪屏。

那么,为什么只在特定的Android设备上出现这个问题?还有没有办法可以禁用它?

英文:

I have created a Custom Splash In My React Native Application & it works well on All iOS Devices & even works on couple of Android devices.

So the issue coming in Android device is when I launch Application by Clicking on App Icon first it shows the Black screen with the App Icon as a Fake Splash & then it shows the custom Splash which.

So is there reason why it's coming only on Specific Android device ?

And is there any way we can disable it ?

答案1

得分: 1

这是解决此问题的最简单方法:

转到 android/app/src/main/res/values/styles.xml
禁用应用程序的预览如下:

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowDisablePreview">true</item> // <--- 添加此行
        // 其他项...
    </style>
</resources>

感谢这个[https://github.com/crazycodeboy/react-native-splash-screen/issues/338#issuecomment-447251703]评论。

英文:

Here is the simplest solution for this problem:

Go to android/app/src/main/res/values/styles.xml
Disable the app's preview as follows:

&lt;resources&gt;
    &lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.AppCompat.Light.NoActionBar&quot;&gt;
        &lt;item name=&quot;android:windowDisablePreview&quot;&gt;true&lt;/item&gt; // &lt;--- ADD THIS
        // Other items...
    &lt;/style&gt;
&lt;/resources&gt;```

thanks to this[https://github.com/crazycodeboy/react-native-splash-screen/issues/338#issuecomment-447251703] comment.

</details>



# 答案2
**得分**: 0

最后,在进行了大量研究后,我找到了为什么在特定Android设备上仅在自定义启动画面之前出现此额外启动画面的根本原因。

原因在于在Android操作系统和更高版本中引入了一个名为“默认启动画面”的附加功能。它会将应用程序图标作为标志,并在启动应用程序时加载到黑屏的中心位置,作为默认的启动画面。

因此,您不需要额外的工作来添加启动画面,它会自动加载。

**重要说明:**

如上所述,它仅适用于运行Android 12或更高版本的设备。 Android 12以下的设备将正常工作,而无需默认启动画面。

**可能的解决方案:**

现在,重要的问题是,如果我们想显示自定义启动画面,我们该如何处理它。为此,我们可以尝试几种可能的解决方案。

**解决方案-1:** 我们可以用自定义启动画面覆盖默认启动画面,但这并不是一个经过尝试和测试的解决方案,但我们绝对可以尝试一下。

**解决方案-2:** 我们可以在默认启动画面后立即显示自定义启动画面,这是经过尝试和测试的可能场景,并且在所有Android设备上都运行良好。唯一的区别是在OS 12+设备上,它将显示默认启动画面和自定义启动画面,而在旧设备上,它将只显示自定义启动画面。

**解决方案-3:** 最后一种可能的解决方案是尝试禁用默认启动画面,但这不是推荐的解决方案。

希望这对每个人有所帮助。

<details>
<summary>英文:</summary>

Finally after doing lots of research I found the root cause of why this additional splash coming only on specific Android devices just before Custom Splash.

So the reason is In Android OS &amp; later OS versions there is an additional Feature presented called &quot;Default Splash&quot;, So What it will do is It will take App Icon as a Logo &amp; will load it in centre of the black screen while launching the Application as a Default Splash.

So you won&#39;t need to do any extra efforts for adding a Splash Screen it will automatically take it. 

**Important Note :**

As mentioned above it will only work on the Android devices running with OS version 12 or higher. Android OS below 12 devices will work normally without Default Splash screen.

**Possible Solutions :**

Now the important question is how we can deal with it if we want to show our on custom splash. So for that there are couple of possible solutions which we can try out.

**Solution-1 :** We can override the Default splash with custom splash, However its not a tried &amp; tested solution but we can definitely try on it

**Solution-2 :** We can show Custom Splash Just after the Default Splash, This is tried &amp; tested possible scenario &amp; works well on all android devices. Only it will make difference will be like on OS 12+ devices it will show Default as well as Custom Splash &amp; on older devices it will show only Custom Splash

**Solution-3 :** Last possible solution is We can try to disable the Default Splash, how ever this is not recommended solution

Hope this will help to everyone.

</details>



huangapple
  • 本文由 发表于 2023年6月5日 13:14:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76403626.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定