Bug 42354 - LaunchMode = LaunchMode.SingleInstance in Mainactivity adds an empty view on startup
Summary: LaunchMode = LaunchMode.SingleInstance in Mainactivity adds an empty view on ...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2016-07-05 12:02 UTC by Fokke Vermeulen
Modified: 2016-09-20 22:26 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Screen which is shown during the loading startup, before reaching the Forms Page (33.97 KB, image/png)
2016-07-05 12:02 UTC, Fokke Vermeulen

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Fokke Vermeulen 2016-07-05 12:02:05 UTC
Created attachment 16571 [details]
Screen which is shown during the loading startup, before reaching the Forms Page

My MainActivity-ActivityLine looks like this:

        Theme = "@style/RebuyTheme",
        Label = "@string/app_name",
        LaunchMode = LaunchMode.SingleInstance,
        ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation

The LaunchMode = LaunchMode.SingleInstance adds an empty view with a navigationBar.

When I remove that line, it's fine.

But I need the singleInstance.

What I have to do, that the Activity is not shown like this. I only want to show the splashscreen (which is perfectly shown) and than directly the normal Forms page
Comment 1 Fokke Vermeulen 2016-07-05 12:23:10 UTC
The MainActivity inherits from FormsApplicationActivity
Comment 2 Jon Douglas [MSFT] 2016-07-06 04:59:39 UTC
Is there a reason you need to use SingleInstance here? SingleInstance is very rarely used and doesn't serve a benefit ontop of using Xamarin.Forms(That I've seen). Ideally only a single instance of an Activity can exist if this mode is enabled.

However with that said, it might be worth your time to read about Tasks in Android in general to understand how this works:


Given that you have a SplashActivity, you most likely want to decorate the "NoHistory = true" to ensure that you cannot go back to the SplashActivity and that Android forgets about it.

So applying this to your MainActivity, effectively when the MainActivity will launch from the intent that your SplashActivity gives, it is saying "Create a new task for this and make this Activity the root. If we do anything else with this, it will become a new separate task." So with that said, it should still behave in the fashion you're expecting. Splash Screen -> Main Activity. The difference will be in the Task Manager in seeing only one Task with your one Activity.

What you are probably seeing is the new Activity being created as the root and then the respective content being swapped into it. Thus you see in order:

Splash Screen -> Main Activity (With the Titlebar label) -> Main Activity with content swapped

You can debug this yourself by putting a breakpoint on the:

global::Xamarin.Forms.Forms.Init(this, bundle);

Line of code which will show the new Task with the single Activity created and then after this gets initialized and loaded it will swap the content in.

In short, you can't really do anything about this behavior with singleInstance. Best thing you could do is inflate a view(progress bar/etc) while the Forms init is being called.
Comment 3 Fokke Vermeulen 2016-07-06 11:50:27 UTC
Changed it to SingleTask. Right now it does what I expected what it should do. So thank you for your help.
Comment 4 Victor Rojas B 2016-09-20 22:26:30 UTC
Hi, I've the same problem with my solution, but I haven´t any LaunchMode in my Activity, but when I run my app, started the Splash, and the empty view showed up for a moment and after appears my MainActivity.

My questions is how can I chance that, because I don´t want to show this empty view between the splash and my MainActivity