C# 活动需要标志\u活动\u新任务标志

C# 活动需要标志\u活动\u新任务标志,c#,android,android-activity,textview,xamarin,C#,Android,Android Activity,Textview,Xamarin,我正在使用Xamarin,当我单击包含电话号码链接的TextView时,我的模拟器执行错误 应用程序输出具有以下输出: [MessageQueue-JNI] Exception in MessageQueue callback: handleReceiveCallback [MessageQueue-JNI] android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity con

我正在使用Xamarin,当我单击包含电话号码链接的TextView时,我的模拟器执行错误

应用程序输出具有以下输出:

[MessageQueue-JNI] Exception in MessageQueue callback: handleReceiveCallback
[MessageQueue-JNI] android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
我需要在哪里设置标志,我应该设置什么

我能帮点忙吗

提前谢谢

编辑

这是我的申请代码:

namespace TestTextViewAutoLink
{
    [Activity (Label = "TestTextViewAutoLink", MainLauncher = true)]
    public class MainActivity : Activity
    {
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            TextView textView = new TextView (this.ApplicationContext);
            textView.AutoLinkMask = Android.Text.Util.MatchOptions.PhoneNumbers; 
            textView.Text = "This is a phone number 0800 32 32 32";

            //Linkify.AddLinks(textView, MatchOptions.PhoneNumbers);

            SetContentView(textView);
        }
    }
}
在上面的代码中,我应该在哪里放置Intent标志

EDIT2

这是我用ActivityFlags.NewTask启动活动的代码

namespace TestTextViewAutoLink
{
    [Activity (Label = "TestTextViewAutoLink", MainLauncher = true)]
    public class MainActivity : Activity
    {
        protected override void OnCreate (Bundle bundle)
        {
            Intent intent= new Intent(this.ApplicationContext, typeof(AutoLinkActivity));
            intent.SetFlags(ActivityFlags.NewTask);
            StartActivity(intent);
        }
    }
}
但是,现在会发生此错误:

android.util.SuperNotCalledException:Activity{TestTextViewAutoLink.TestTextViewAutoLink/TestTextViewAutoLink.MainActivity}未调用super.onCreate()

我如何才能让代码正常工作?

试试这个

错误本身就有意义

Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag
范例

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

您没有在超类中编写对onCreate函数的调用

base.OnCreate(bundle)

protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);
            Intent intent= new Intent(this.ApplicationContext, typeof(AutoLinkActivity));
            intent.SetFlags(ActivityFlags.NewTask);
            StartActivity(intent);
        }

没有调用super.onCreate()
添加super.onCreate()OP在Xamarin.Android的上下文中提出了这个问题。你的答案行不通。您已经在Android Studio的上下文中提供了代码。