[Mono-bugs] [Bug 639679] New: StartActivity() requiring intent to have FLAG_ACTIVITY_NEW_TASK and not assuming the caller's task affinity

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Sep 15 21:59:30 EDT 2010



           Summary: StartActivity() requiring intent to have
                    FLAG_ACTIVITY_NEW_TASK and not assuming the caller's
                    task affinity
    Classification: Mono
           Product: MonoDroid
           Version: SVN
          Platform: 64bit
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Runtime
        AssignedTo: mkestner at novell.com
        ReportedBy: jondick at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.55 Safari/534.3

So, according to Android docs, if we startactivity from another activity, by
default, the task affinity of the new activity should be to belong to the same
Task that the calling activity belongs to.

However, I'm noticing that I get an error:
android.util.AndroidRuntimeException: Calling startActivity() from outside of
an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really
what you want?
at android.app.ApplicationContext.startActivity()

Check out the code I'm using in the Additional Notes.  But, I'm passing 'this'
as the context where this is an Activity, however the stacktrace is showing
that ApplicationContext seems to be what's used.  Perhaps this is the problem? 
The context needs to be the Activity's context?

I know if I add the ActivityFlags.NewTask (FLAG_ACTIVITY_NEW_TASK) it works,
but I believe the point is, I should not have to do that.

Reproducible: Always

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;

namespace MonoDroidTesting
    public class SimpleDataList : ListActivity
        public SimpleDataList(IntPtr handle)
            : base(handle)

        protected override void OnCreate(Bundle bundle)

            string[] items = new string[] {
                "Item One",
                "Second Item",
                "Number Three",
                "Fourth Option",
                "Fifth One",
                "Sixth Item",
                "Number Seven",
                "This is Eight",
                "Ten Speed"

            this.ListAdapter = new ArrayAdapter<string>(this,
Android.R.Layout.SimpleListItem1, items);
            this.ListView.ItemClick += new

        void ListView_ItemClick(object sender, ItemEventArgs e)
            //Toast.MakeText(this, "test", ToastLength.Short).Show();
            var intent = new Intent().SetClassName(this.BaseContext,
            //    intent.AddFlags(ActivityFlags.NewTask);



Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list