Bug 31087 - Wrong order of OnResume
Summary: Wrong order of OnResume
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2015-06-13 07:34 UTC by roger.schmidlin
Modified: 2015-06-17 10:57 UTC (History)
1 user (show)

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


Attachments
empty intent after OnCreate or OnResume (445.40 KB, image/png)
2015-06-13 07:42 UTC, roger.schmidlin
Details
DemoProject Wrong order of OnResume and Intent empty (363.85 KB, application/zip)
2015-06-16 11:05 UTC, roger.schmidlin
Details
adding a splash screen in front of the MainActivity ... please try again (515.16 KB, application/zip)
2015-06-17 09:21 UTC, roger.schmidlin
Details


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:
Status:
RESOLVED NOT_REPRODUCIBLE

Description roger.schmidlin 2015-06-13 07:34:11 UTC
The OnResume of the PCL Project gets called before the Android activity OnResume. I would expect my Android MainActivity OnResume to be called first (Entry Point of App).

Might this also be the problem, why I get an empty intent in the Android activity? Maybe gets consumed by the PCL Project
Comment 1 roger.schmidlin 2015-06-13 07:42:31 UTC
Created attachment 11596 [details]
empty intent after OnCreate or OnResume
Comment 2 Rui Marinho 2015-06-15 06:25:08 UTC
Hi Roget, thank you for taking the time to submit the bug. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue we would very much appreciate it.

Warm regards,
Xamarin Forms Team
Comment 3 roger.schmidlin 2015-06-16 11:05:13 UTC
Created attachment 11622 [details]
DemoProject Wrong order of OnResume and Intent empty

To check the order just run the app in debug mode. Hit home button and then return to app: you can see the order of the calls in the debug window.
Also notice that the intent is always null! You can also try to go to youtube app and share a video clip with app. Intent also gets called but with empty intent.
Comment 4 Rui Marinho 2015-06-17 05:21:07 UTC
Hi roger i just tried and i m not able to reproduce the problem , i get the Intent to be Main when hitting home OnResume, and if i share via youtube i get the intent SEND OnResume . 

> android.intent.action.MAIN: OnResume in Activity: Intent Action = {0}
> android.intent.action.MAIN: OnResume in Activity: Intent Action = {0}
> android.intent.action.SEND: OnCreate in Activity: Intent Action = {0}
> android.intent.action.SEND: OnCreate in Activity: Intent Action = {0}
Comment 5 roger.schmidlin 2015-06-17 05:53:23 UTC
Hi Rui

Two things:

1. It looks like in your debug message it says android.intent.action.MAIN but still shows Action = 0 which indicates a null. This action is read in my demo code. It looks like I can't read the intent in my activity. Do you have an explanation for that?

2. After hitting home and then return I get output like below. I believe you missed a part in your debug. Can you verify this for me?

Thanks for your help,
Roger


[Mono] Assembly Ref addref Xamarin.Forms.Platform.Android[0xaf16e460] -> System.Xml[0x9c068100]: 3
OnResume in PCL
OnResume in PCL
OnResume in PCL
OnResume in PCL
android.intent.action.MAIN: OnResume in Activity: Intent Action = {0}
android.intent.action.MAIN: OnResume in Activity: Intent Action = {0}
Comment 6 Rui Marinho 2015-06-17 06:17:36 UTC
Well that's just because Debug.WriteLine was using overload 4 (string category, string message).


Change your debug code line to:

System.Diagnostics.Debug.WriteLine (string.Format("OnCreate in Activity: Intent Action = {0}", Intent.Action ));

to get:

OnCreate in Activity: Intent Action = android.intent.action.SEND
OnCreate in Activity: Intent Action = android.intent.action.SEND
OnResume in Activity: Intent Action = android.intent.action.SEND
OnResume in Activity: Intent Action = android.intent.action.SEND

Thanks
Comment 7 roger.schmidlin 2015-06-17 09:21:26 UTC
Created attachment 11644 [details]
adding a splash screen in front of the MainActivity ... please try again

Ah, I can see the problem with the debug message. I also found out why it is working with this demo. 
BUT ...
I created a new version that is actually built more like my app. I put another activity in front. Now, you shouldn't see the loaded intent anymore.
It has to do with the MainLauncher = false in the MainActivity. It seems like it has to be true in order to receive and intent properly. And that shouldn't really be that way, right?
But in my example I have a little splash screen to start up.

Can you please give this another try?
Comment 8 Rui Marinho 2015-06-17 10:57:55 UTC
That is not related with Xamarin.Forms, sorry. For now we are supporting a single Activity and as the MainLauncher=True to interact with Forms.