Sto realizzando un'app in cui voglio passare un array json tra 2 attività. Come passare json arry da un'attività all'altra tramite intenti in Android. qualcuno può aiutarmi su questo ?? graziepassando jsonarray da 1 attività ad un altro
risposta
Converti JsonArray in String quindi collegalo a Intent e invialo.
JSONObject jObject = new JSONObject("Your Json Response");
Intent obj_intent = new Intent(Main.this, Main1.class);
Bundle b = new Bundle();
b.putString("Array",jObject4.toString());
obj_intent.putExtras(b);
Dove jObject4 è Oggetto JSON.
Entra in prossima pagina:
Bundle b = getIntent().getExtras();
String Array=b.getString("Array");
Intent intent = new Intent(your_activity.this, new_activity.class);
intent.putExtra("jsonArray", mJsonArray.toString());
startActivity(intent);
Nel prossimo Activity
Intent intent = getIntent();
String jsonArray = intent.getStringExtra("jsonArray");
try {
JSONArray array = new JSONArray(jsonArray);
System.out.println(array.toString(2));
} catch (JSONException e) {
e.printStackTrace();
}
Risolto il mio problema !! – SAHIL
intent.putExtra ("jsonArray", mJsonArray.toString()); cos'è mJsonArray qui? –
mJsonArray è l'oggetto di JSONArray –
- 1. Passando Array ad un select_tag
- 2. Passando un blocco ad un delayed_job
- 3. Errore durante il passaggio di un oggetto da un attività ad un altro (Usando Parcelable)
- 4. Passando un URL con staffe ad arricciarsi
- 5. simplejson: Stringa da JSONArray
- 6. Come inviare dati da un frammento ad un altro frammento?
- 7. Android: Passando AppWidgetId ad un Servizio di
- 8. R passando il frame di dati ad un altro programma usando system()
- 9. Segue ad un altro storyboard?
- 10. Trasferisci dati da un database ad un altro database
- 11. Copia una colonna da un database ad un altro
- 12. Meteor, come accedere ad un helper da un altro helper?
- 13. lancio di attività da un altro Applicazione per android
- 14. C# - Convertire un Enum ad un altro
- 15. Copia NSMutableArray ad un altro
- 16. "include" un file javascript ad un altro
- 17. git log la differenza tra 1 ramo da un altro
- 18. Passando immagine a un altro controller View (Swift)
- 19. Redirect da pagina asp.net ad un altro utilizzando funzione javascript
- 20. esportazione di plug-in installati da Eclipse ad un altro
- 21. Spostamento di elementi da std :: vector ad un altro
- 22. Importare una classe da una cartella ad un altro livello
- 23. Come visualizzare un avviso/errore se l'ID risorsa utilizzato appartiene ad un altro layout di attività
- 24. Esegui uno script python da un altro script python, passando in args
- 25. Passando un argomento IEnumerable vuoto ad un metodo
- 26. Come rimuovere un elemento specifico da un JSONArray?
- 27. SimpleXML: aggiungi un albero ad un altro
- 28. Aggiunta di un dizionario ad un altro
- 29. attività di invio o reindirizzamento ad altre attività
- 30. Kotlin: Iterate attraverso un JSONArray
E 'solo di passaggio JSONObject, non JSONArray. – ChihHao