Bug 17485 - When Intent uses NewTask flag Infrastructure fails to start new activity
Summary: When Intent uses NewTask flag Infrastructure fails to start new activity
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 4.12.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2014-01-29 12:06 UTC by Miha Valencic
Modified: 2017-06-29 17:49 UTC (History)
4 users (show)

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


Attachments
Two sample projects to help confirm the bug. (821.17 KB, application/zip)
2017-06-29 17:49 UTC, Tom Opgenorth
Details

Description Miha Valencic 2014-01-29 12:06:41 UTC
While playing with MvvmCross I encountered a situation, where an Activity cannot be started if it has been previously started, if one uses ActivityFlags.NewTask flags on an intent, which is used to start an activity.


I've demonstrated this in code here: https://github.com/skyflyer/XamarinAndroidNewTaskIntentFlag

I've also added an equivalent project in Java (developed using Eclipse), which works as expected.

The situation is as follows:

Start ActivityA, then from there (say on a button click) start ActivityB (with flag set to NewTask), then in ActivityB, start ActivityA with intent with flags set to NewTask. The ActivityA will not start, if you're using Xamarin.Android. I'm using XamarinStudio (alpha channel):

Xamarin Studio
Version 4.3.1 (build 5)
Installation UUID: c8c12daf-0622-4167-a85a-cf0db7a634b2
Runtime:
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 302060000

Xamarin.Android
Version: 4.12.0 (Trial Edition)
Android SDK: /Users/miha/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
Comment 1 Prashant manu 2014-01-30 05:12:59 UTC
I have run the attached project from link: https://github.com/skyflyer/XamarinAndroidNewTaskIntentFlag on following builds:

All Mac
X.S 4.3.1(build 5)
Mono 3.2.6
X.Android 4.12.0-14

Application displaying me button 'First' on First one page when launch on device. After clicking on this button it redirects to Second one page which shows me button 'Go to main' . When I click on this button to back on First page it does not redirect to First one page. This is the Application Output for the same: https://gist.github.com/saurabh360/34a7b3cd75edaec91949 

I am not sure is is it same Issue which Miha facing or is it something different.
Comment 2 Miha Valencic 2014-01-30 05:17:03 UTC
Prashant,

this is also the behaviour I'm seeing and it is wrong, IMHO. When clicking the "Go to main" you should see the First page again. If you comment the intent.setFlags lines in both activities, you will see the how it is supposed to work.
Comment 3 pat 2014-09-05 08:23:29 UTC
Whilst I think the beahavior we are seeing is stupid it does not look like a xamarin thing as I repro'd it in vanilla Android.

Miha,

I have a workaround for this in MVVM Cross if you are interested

Pat
Comment 4 Miha Valencic 2014-09-05 09:10:20 UTC
Pat, no need for a workaround, but thanks. Interesting that you've been able to repro it with vanilla Android, as I have not (I've shared a working eclipse project (see above)).
Comment 5 Tom Opgenorth 2017-06-29 17:49:00 UTC
I can confirm this bug as a Xamarin (but not Android) but. 

I've attached a zip with two samples - on in Xamarin.Android that shows the error. Another project (using Kotlin) where things seem to work correctly.
Comment 6 Tom Opgenorth 2017-06-29 17:49:48 UTC
Created attachment 23222 [details]
Two sample projects to help confirm the bug.

Note You need to log in before you can comment on or make changes to this bug.