Commit 4ef2404157f1e4d9cb4168c669516fb0470d8535
1 parent
8d573e63
Retour du JSONObject dans l'activité principale
Showing
2 changed files
with
14 additions
and
11 deletions
Show diff stats
PremiereActivite/app/src/main/java/com/example/app_10p5/CarteActivite.java
... | ... | @@ -195,17 +195,9 @@ public class CarteActivite extends Activity implements ASyncResponse { |
195 | 195 | /* Retour du NetworkThread */ |
196 | 196 | @Override |
197 | 197 | public void processFinish(JSONObject output) { |
198 | - try { | |
199 | - if (output.get("status").equals("ok")) { | |
200 | - Toast.makeText(this, "Tout c'est bien passé: " + output.get("status").toString(), Toast.LENGTH_LONG).show(); | |
201 | - } else { | |
202 | - Toast.makeText(this, "Erreur lors du traitement de la requête: " + output.get("status").toString(), Toast.LENGTH_LONG).show(); | |
203 | - } | |
204 | - } catch (Throwable t) { | |
205 | - Toast.makeText(this, "WTF, le cancer est dans l'application!! " + t.toString(), Toast.LENGTH_LONG).show(); | |
206 | - } | |
207 | - | |
198 | + Intent intent = new Intent(this, CarteActivite.class); | |
199 | + intent.putExtra("json", output.toString()); | |
200 | + setResult(0, intent); | |
208 | 201 | finish(); |
209 | - return; | |
210 | 202 | } |
211 | 203 | } | ... | ... |
PremiereActivite/app/src/main/java/com/example/app_10p5/MainActivite.java
... | ... | @@ -258,6 +258,17 @@ public class MainActivite extends FragmentActivity implements ASyncResponse { |
258 | 258 | @Override |
259 | 259 | protected void onActivityResult(int requestCode, int resultCode, Intent data){ |
260 | 260 | //TODO: faire des choses avec ca |
261 | + | |
262 | + try{ | |
263 | + JSONObject json = new JSONObject(data.getStringExtra("json")); | |
264 | + Toast.makeText(this, "Status: " + json.getString("status"), Toast.LENGTH_SHORT).show(); | |
265 | + | |
266 | + } | |
267 | + catch (Throwable t){ | |
268 | + Toast.makeText(this, "WTF, le cancer est dans l'application!!", Toast.LENGTH_LONG).show(); | |
269 | + } | |
270 | + | |
271 | + | |
261 | 272 | switch (requestCode) { |
262 | 273 | case STATE_COMMANDE: |
263 | 274 | break; | ... | ... |