Which image is displayed on my Samsung Android tablet when I start my application? Can I change it?

asked 2023-01-14T11:16:24.1433333+00:00
Kim Strasser 341 Reputation points

I get the following screen on my Samsung tablet when I start debugging my Android application:

image2.jpeg

A short time later my splash image is displayed:

image1.jpeg

And finally a short time later the bar with the icons at the bottom is removed:

image0.jpeg

Which image is displayed on my Samsung tablet when I start my application? Can I change it? I thought that my splash image would be the first image on the screen but there is another image on the screen before my splash screen is displayed.

Is it possible to hide the bar with the icons when I start my application or is it normal that this bar is displayed when I start an application on an Android device?

I use target Android version 13, .NET 6.0 and Visual Studio for Mac 17.5 Preview (17.5 build 1095).

I don't use the .NET MAUI template to create my Android project but I use this code in my csproj to use .NET MAUI:

<UseMaui>true</UseMaui> <UseMauiEssentials>true</UseMauiEssentials>

I use the following code in my Activity1.cs to display my splash image and to remove the bar with the icons:

 protected override void OnCreate(Bundle bundle)
 {
     ...
     DisplayMetrics displayMetrics = new DisplayMetrics();
     WindowManager.DefaultDisplay.GetRealMetrics(displayMetrics);
     int w1 = displayMetrics.WidthPixels;
     int h1 = displayMetrics.HeightPixels;
     _game = new Game1(w1, h1);
     
     _game.OnLoadingContent += G_OnLoadingContent;
     layout = new FrameLayout(this.ApplicationContext);
     layout.AddView((View)_game.Services.GetService(typeof(View)));
     splashView = new ImageView(this.ApplicationContext);
     ((ImageView)splashView).SetBackgroundResource(Resource.Drawable.splash_screen);
     layout.AddView(splashView);
     SetContentView(layout);
     ...
     _game.Run();
     //Hide action bar
     View vw = (View)_game.Services.GetService(typeof(View));
     vw.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky);
     vw.SetOnSystemUiVisibilityChangeListener(new MyUiVisibilityChangeListener(vw));
 }

 //Hide action bar
 private class MyUiVisibilityChangeListener : Java.Lang.Object, View.IOnSystemUiVisibilityChangeListener
 {
        View targetView;
        public MyUiVisibilityChangeListener(View v)
        {
            targetView = v;
        }
        public void OnSystemUiVisibilityChange(StatusBarVisibility v)
        {
            if (targetView.SystemUiVisibility != ((StatusBarVisibility)SystemUiFlags.HideNavigation | (StatusBarVisibility)SystemUiFlags.ImmersiveSticky | (StatusBarVisibility)SystemUiFlags.LayoutStable | (StatusBarVisibility)SystemUiFlags.LayoutHideNavigation | (StatusBarVisibility)SystemUiFlags.LayoutFullscreen | (StatusBarVisibility)SystemUiFlags.Fullscreen))
            {
                targetView.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.HideNavigation | (StatusBarVisibility)SystemUiFlags.ImmersiveSticky | (StatusBarVisibility)SystemUiFlags.LayoutStable | (StatusBarVisibility)SystemUiFlags.LayoutHideNavigation | (StatusBarVisibility)SystemUiFlags.LayoutFullscreen | (StatusBarVisibility)SystemUiFlags.Fullscreen;
            }
        }
 }

public override void OnWindowFocusChanged(bool hasFocus)
{
    base.OnWindowFocusChanged(hasFocus);
    if (hasFocus)
        SetImmersive();
}

private void SetImmersive()
{
    string except = string.Empty;
    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Kitkat)
    {
        try
        {
            //Hide action bar
            View vww = (View)_game.Services.GetService(typeof(View));
            vww.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky);
            vww.SetOnSystemUiVisibilityChangeListener(new MyUiVisibilityChangeListener(vww));
        }
        catch (Exception ex)
        {
            except = ex.ToString();
        }
    }
}

private void G_OnLoadingContent(object sender, System.EventArgs e)
{
    layout.RemoveView(splashView);
}

In addition I used 'View.SystemUiVisibility' on other Android versions to hide the action bar but now on Android version 13 Visual Studio displays: 'View.SystemUiVisibility' is obsolete: 'deprecated' And Visual Studio displays: 'Display.GetRealMetrics(DisplayMetrics?)' is obsolete: 'deprecated'

Can I still use 'View.SystemUiVisibility' and Display.GetRealMetrics on Android version 13?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
868 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,905 questions
No comments
{count} votes

2 answers

Sort by: Most helpful
  1. answered 2023-01-16T08:54:42.9833333+00:00
    Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 10,981 Reputation points Microsoft Employee

    Hello,

    On MAUI, there is official API to change the image of SplashScreen. Please refer to Add a splash screen to a .NET MAUI app project.

    In addition I used 'View.SystemUiVisibility' on other Android versions to hide the action bar but now on Android version 13 Visual Studio displays: 'View.SystemUiVisibility' is obsolete: 'deprecated' And Visual Studio displays: 'Display.GetRealMetrics(DisplayMetrics?)' is obsolete: 'deprecated'

    SystemUiVisibility has been deprecated on Android 11, on Android 13, you need to use WindowInsetsController to hide status bar.

    The following link and sample could be helpful for you:

    if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.R)  
    {  
    	Window.SetDecorFitsSystemWindows(false);  
    	var it = Window.InsetsController;  
    	it.Hide(WindowInsets.Type.XXX);  
    	it.SystemBarsBehavior = (int)WindowInsetsControllerBehavior.ShowTransientBarsBySwipe;  
    }  
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread.

    No comments

  2. answered 2023-01-16T08:59:29.7533333+00:00
    Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 10,981 Reputation points Microsoft Employee

    Hello,

    On MAUI, there is official API to change the image of SplashScreen. Please refer to Add a splash screen to a .NET MAUI app project.

    In addition I used 'View.SystemUiVisibility' on other Android versions to hide the action bar but now on Android version 13 Visual Studio displays: 'View.SystemUiVisibility' is obsolete: 'deprecated' And Visual Studio displays: 'Display.GetRealMetrics(DisplayMetrics?)' is obsolete: 'deprecated'

    SystemUiVisibility has been deprecated on Android 11, on Android 13, you need to use WindowInsetsController to hide status bar.

    The following link and sample could be helpful for you:

    if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.R)  
    {  
    	Window.SetDecorFitsSystemWindows(false);  
    	var it = Window.InsetsController;  
    	it.Hide(WindowInsets.Type.XXX);  
    	it.SystemBarsBehavior = (int)WindowInsetsControllerBehavior.ShowTransientBarsBySwipe;  
    }  
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread.