0

I was following this answer and trying to adapt it to a List with no success.

The goal is to loop the Activity x amount of times and keep a list that moves a List of a custom Object I have preciously created.

what I am trying to do is:

        var MySerializedObject = JsonConvert.SerializeObject(partList);
        Intent intent = new Intent(this, typeof(ActComponentForm));
        intent.PutExtra("partList", MySerializedObject);

And I try to use the intent doing:

List<Components.Component> listParted = new List<Components.Component>();
 try
    {
      var MyJsonString = Intent.GetStringExtra("partList");
      listParted = JsonConvert.DeserializeObject<List<Components.Component>>(MyJsonString);

    }

With zero sucess as the list doesn't get returned.

PeterKima
  • 43
  • 1
  • 10
  • Do you have some error? – qubuss Dec 17 '17 at 21:56
  • Yes. I get a "System.ArgumentNullException" – PeterKima Dec 17 '17 at 21:58
  • When do you put your extras in first activity I think is not a string extra. Try to use in secent activity not getStringExtra but getExtra or something like this. – qubuss Dec 17 '17 at 22:01
  • Please check your `MySerializedObject`, make sure it is right. You can also use this `Intent.PutParcelableArrayListExtra()`: https://developer.android.com/reference/android/content/Intent.html#putParcelableArrayListExtra(java.lang.String, java.util.ArrayList extends android.os.Parcelable>) method to pass data. The later is better than the previous in performance. – Robbit Dec 18 '17 at 02:53

0 Answers0