我正在使用Xamarin,當我點擊一個TextView時,我的模擬器正在執行錯誤,該TextView有一個電話號碼的鏈接。活動需要FLAG_ACTIVITY_NEW_TASK標誌
應用輸出有這樣的輸出:
[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);
}
}
}
其中,在上面的代碼,我應該放在意向標誌?
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:活動{TestTextViewAutoLink.TestTextViewAutoLink/testtextviewautolink.MainActivity}沒有通過調用super.onCreate()
我該如何獲得此代碼的工作?
[選中此選項(http://stackoverflow.com/questions/8599657/dialing-a-phone-call-on-click-of-textview-in-android) –
'沒叫通過super.onCreate()'add super.onCreate() –