Been trying this for a while now. I am trying to pass JsonArray from one intent to another. Here is my code.
Intent intent = new Intent(this, DownloadService.class);
Bundle bundle = new Bundle();
JSonArrayParser jSonArrayParser = new JSonArrayParser(dealTypeList);
bundle.putParcelable("jsonArray", jSonArrayParser);
intent.putExtra("deals_list", bundle);
this.startService(intent);
JSonArrayParser implements Parcelable.
I have checked that the JSonArrayParser is being populated with the Jsonarray as expected before passing it to the Bundle.
The issue is when I read it out on the other intent. I get a null back for the JsonArray.
Here is what I have so far.
if(intent.hasExtra("jsonArray"))
{
JSonArrayParser jSonArrayParser = null;
Bundle bundle = intent.getParcelableExtra("jsonArray");
if (bundle != null) {
jSonArrayParser = bundle.getParcelable("deals_list");
String jsonMyObject = bundle.getString("deals_list");
jSonArrayParser = intent.getParcelableExtra("deals_list");
if(jSonArrayParser != null)
{
JSONArray jsonArray = jSonArrayParser.getJsonArray();
String ssad = "";
}
}
}
I have tried a lot of different variation to try and read the value out but it seems the JSONArray is always null.
Have searched through the internet before posting this. Please if someone can help that would be great.
Thanks in advance.
EDIT:
I have tried passing JSonArray as string as following but that didnt seem to start the intent at all.
Intent intent = new Intent(your_activity.this, new_activity.class);
intent.putExtra("jsonArray", dealTypeList.toString());
startActivity(intent);