Xamarin在活动之间传递数据
我无法在2个活动之间共享数据:
活动1
homeButton.Click += delegate { var second = new Intent(this, typeof(SecondPage)); second.PutExtra("reg", "qwe"); StartActivity (typeof(SecondPage)); }
Acitvity2(SecondPage)
string txt = Intent.GetStringExtra ("reg") ?? "null"; Console.WriteLine (txt);
仍然得到null,有什么建议吗?
首先,您应该传递您创建的意图:
homeButton.Click += delegate { var second = new Intent(this, typeof(SecondPage)); second.PutExtra("reg", "qwe"); StartActivity (second); }