Normally, if I want to start a new activity I can use
StartActivity(typeof(foo));
This is fine.
I can also set an intent
Intent i = new Intent(this, typeof(foo));
StartActivity(i);
Problem is this. I have Activity A. This fires off Activity B. However, I need to fire off Activity B after using PutExtra on an intent. If I do
Intent i = new Intent(this, typeof(ActivityB));
monodroid gets rightly annoyed as I’m defining a new Intent from within an Activity.
Is there a way to do this
(psuedocode)
[Activity]
public partial class A
{
protected override void OnCreate(Bundle savedInstance)
{
SetContentView(Resource.Layout.layout);
Button btnClick = FindViewById<Button>(Resource.Id.btnClicky);
btnClick.Click += new EventHandler(button_click);
}
private void button_Click(object s, EventArgs e)
{
Intent i = new Intent(this, typeof(B)); // <- gets annoyed
i.PutExtra("foo", 1);
i.PutExtra("bar", true);
StartActivity(i);
}
}
Any help here would be appreciated.
PFJ
Looks like I needed to add a using which wasn’t needed elsewhere.
Thanks for the answers and sorry for the delay in getting back 🙂
Promise that in future, I’ll make sure things are clearer.