How To Pass Json Data Form One Intent to Another.

Report
Question
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.

Please explain why do you think this question should be reported?

Report Cancel
// 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

Leave an comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>