Android Question Splash screen in Android 12

Hello
How can I make my b4a splash screen compatible with Android 12?
As you know, there is a mandatory splash in Android 12 that displays the program icon in a small form and after a few seconds the program starts. This has caused my app to have two splashes on Android 12!
Here is how to implement it in Android Studio, but I don't know how to use it in B4A:
Thankful
 
Solution
You can't do that from B4A as you need to add code to the Main activity creation event which is not exposed in B4A
It is possible. There is an _oncreate hook: https://www.b4x.com/android/forum/threads/inline-java-code.50141/#content

B4X:
#If JAVA
import androidx.core.splashscreen.SplashScreen;
public void _onCreate() {
    BA.Log("onCreate");
      SplashScreen splashScreen = SplashScreen.installSplashScreen(this);
}
#End If

I've attached a project that implements some of the steps. It looks like the simplest solution is to remove the custom splash activity.

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

agraham

Expert
Licensed User
Longtime User
Changing the colour in the manifest to pure blue worked for me., though it is the colour of the replacement splash screen so I don't understand
"but the Android 12 mandatory splash background is still blue"
as I understood this splash screen replaces the mandatory splash screen.
B4X:
CreateResource(values, colors.xml,
<resources>
    <color name="window">#FF0000FF</color>
</resources>
Nor do I understand this
"Another problem is that the splash screen icon is round, how can I make it rectangular and how can I change its size?"
 
Upvote 0
I don't understand. Just lay out the splash screen in the Designer as you want it. In the example case it is Splash.bal.
I don't know why you don't understand, maybe it's because you don't know the nature of splash screen in Android 12.
If you have worked with Android 12, you will understand that it has a mandatory splash screen, which by default only displays the application icon in a small form in the middle of the screen.
I want to enlarge the icon of that forced Android 12 splash. In this source, Erel has done this, but because the icon is enlarged, only a piece of it is displayed and it is not complete.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I perfectly understand the nature of the splash screen in Android 12. It's you that doesn't understand the posted code.
Erel has done this
No he hasn't. Look at the codes he and I posted. Both replace the default Android12 splash screen with the Main activity of the app and add an Activity named Activity2 to replace it as the starting Activity of the app when the splash screen times out. .The layout for Main, Splash.bal, contains an Imageview that loads a png of the the B4X logo. You can make this activity have whatever layout you want for your own splash screen.
 
Upvote 0
Top