How To Pass Json Data Form One Intent to Another.
ReportQuestion
3 years ago 1390 views
Create Json object in first intent then put it in intent as string then receive it as string on second activity the use JsonParser to parse string as json object.
// Step to prepare Json Object and Put in Intent Extra as String
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("address",address);
jsonObject.addProperty("countries_name",country);
jsonObject.addProperty("state",state);
jsonObject.addProperty("city",city);
Intent intent = new Intent(context,NextActivity.class); intent.putExtra("form","user"); intent.putExtra("user",jsonObject.toString()); // Recieve String data From Intent as String and Parse using JsonParsor String data = getIntent().getStringExtra("user"); JsonObject intentData = new JsonParser().parse(data).getAsJsonObject();
Thread Reply