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,17 +195,9 @@ public class CarteActivite extends Activity implements ASyncResponse { | ||
195 | /* Retour du NetworkThread */ | 195 | /* Retour du NetworkThread */ |
196 | @Override | 196 | @Override |
197 | public void processFinish(JSONObject output) { | 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 | finish(); | 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,6 +258,17 @@ public class MainActivite extends FragmentActivity implements ASyncResponse { | ||
258 | @Override | 258 | @Override |
259 | protected void onActivityResult(int requestCode, int resultCode, Intent data){ | 259 | protected void onActivityResult(int requestCode, int resultCode, Intent data){ |
260 | //TODO: faire des choses avec ca | 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 | switch (requestCode) { | 272 | switch (requestCode) { |
262 | case STATE_COMMANDE: | 273 | case STATE_COMMANDE: |
263 | break; | 274 | break; |