Note that there are some explanatory texts on larger screens.

plurals
  1. POWrong Intent getting used
    primarykey
    data
    text
    <p>UPDATE: It seems like in my ActivityCentresPage it isn't getting the correct intent. Is there a special way I need to get the intent from a notification?</p> <p>I added a new key to my intent, and my ActivityCentresPAge displays it as null, even though there is a value. What intent is my Activity getting?</p> <p>I'm building my Receiver to handle GCM messages, and some Intents aren't working.</p> <p>Here's my code</p> <pre><code>private Intent getIntent(String action, JSONObject obj) { Intent intent = new Intent(ctx, ActivityMain.class); if (action.equals("home")) { intent = new Intent(ctx, ActivityMain.class); } else if (action.equals("view_timetable")) { intent = new Intent(ctx, ActivityViewTimetable.class); } else if (action.equals("invite_friends")) { intent = new Intent(ctx, ActivityInviteFriends.class); } else if (action.startsWith("venue_")) { try { intent = new Intent(ctx, ActivityCentrePage.class); Log.d("FUApp", obj.getString("name")); BaseActivity bAct = new BaseActivity(); intent.putExtra(bAct.ExtraKeyCentreName, obj.getString("name")); intent.putExtra(bAct.ExtraKeyCentreDist, "Not Available"); intent.putExtra(bAct.ExtraKeyCentreJSON, obj.toString()); intent.putExtra(bAct.ExtraKeyCentrePostcode, "none"); } catch (JSONException e) { Log.e("FUApp", e.getMessage()); } } else if (action.equals("")) { //intent = new Intent(ctx, .class); Toast.makeText(ctx, "Empty", Toast.LENGTH_SHORT).show(); } else { intent = new Intent(ctx, ActivityMain.class); } return intent; } </code></pre> <p>And </p> <pre><code>Intent intent = new Intent(ctx, ActivityMain.class); if (to_load_action != null) { intent = getIntent(to_load_action, to_load_obj); } for (int a = 0;a &lt; todo_items.length();a++) { JSONObject todo_item = new JSONObject(); String action = ""; String miniAction = ""; try { todo_item = todo_items.getJSONObject(a); action = todo_item.getString("action"); miniAction = todo_item.getString("action_title"); } catch (JSONException e) { Log.d("FUApp", e.getMessage()); } Intent intent2 = getIntent(action, todo_item); PendingIntent pIntent2 = PendingIntent.getActivity(ctx, 0, intent2, 0); mBuilder.addAction(0, miniAction, pIntent2); } PendingIntent pIntent = PendingIntent.getActivity(ctx, 0, intent, 0); mBuilder.setContentIntent(pIntent); </code></pre> <p>When the to_load_action and action (in the for loop) both start with venue_ when I click on the main notification, the intent from addAction is called.</p> <p>Can anyone see what I've got wrong here?</p> <p>EDIT: This line</p> <pre><code>Log.d("FUApp", obj.getString("name")); </code></pre> <p>Outputs the correct information, so two different sets of data are being passed to the method. Also, if the to_load_action doesn't start with venue_, and the action in the for loop does, everything works fine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload