Xamarin Passing data with Activities

Activity 1

Intent intent = new Intent(this, typeof(Activity2));

//intent.PutExtra(“UserID”, 1);
//intent.PutExtra(“Username”, “Joseph”);

User user = new User()
{
UserID = 1,
UserName = mUsername.Text,
Password = “password”
};

intent.PutExtra(“User”, JsonConvert.SerializeObject(user));

this.StartActivity(intent);
this.OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom);

 

Activity 2

User mLoggedOnUser;

mLoggedOnUser = JsonConvert.DeserializeObject<User>(Intent.GetStringExtra(“User”));

 

 

 

Add Comment