UPDATE: It seems that in my ActivityCentresPage this is not the right intention. Is there a special way to get an intention from a notification?
I added a new key to my intention, and my ActivityCentresPAge displays it as null, although there is a value. What intention do I get?
I am creating my own receiver for handling GCM messages, and some intentions do not work.
Here is my 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("")) {
AND
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 < 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);
When to_load_action and the action (in the for loop) start at the meeting point, when I click on the main notification, the addAction intent is called.
Can anyone see what I'm wrong here?
EDIT: This line
Log.d("FUApp", obj.getString("name"));
Displays the correct information, so two different data sets are passed to this method. Also, if to_load_action does not start at meeting point_, and the action in the for loop does, everything works fine.