I'm having issue if the app isn't in memory when the notification is followed. The backstack won't be created. I've followed the steps according to the developers guide. Please show me the bit I've missed otherwise I'll have to route all intents through my HomeActivity
in order to create the backstack manually on following intent.
AndroidManifest.xml:
<activity
android:name=".activity.HomeActivity"
android:clearTaskOnLaunch="true"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:icon="@drawable/actionbar_logo"
android:label="@string/activity_label_home"
android:launchMode="singleTask"
android:parentActivityName=".activity.Start"
android:windowSoftInputMode="stateAlwaysHidden" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.Start" />
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activity.ChatActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:label="@string/activity_label_in_chat"
android:parentActivityName=".activity.HomeActivity"
android:windowSoftInputMode="stateHidden"
tools:ignore="UnusedAttribute" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".activity.HomeActivity" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.myapp.chat" />
</intent-filter>
</activity>
Building notification:
final String chatId = cursor.getString(cursor.getColumnIndexOrThrow(MessageColumns.CHAT));
final Intent chat = new Intent(c, ChatActivity.class);
chat.putExtra(ChatActivity.EXTRA_CHAT_ID, chatId);
PendingIntent intent = TaskStackBuilder.create(c).addNextIntentWithParentStack (chat).getPendingIntent (0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder (c);
final NotificationManagerCompat nm = NotificationManagerCompat.from (c);
builder
.setSmallIcon (R.drawable.ic_stat_notification)
.setContentIntent (intent)
.setGroup (GROUP_KEY_MYAPP)
.setGroupSummary (true);
Notification notification = builder.build ();
nm.notify(NOTIFICATION_ID, notification);
On handling home click from actionbar:
public void onHomeActionDefault (final Activity baseActivity) {
Keyboard.close (baseActivity);
Intent upIntent = NavUtils.getParentActivityIntent (baseActivity);
if (null != upIntent) {
if (NavUtils.shouldUpRecreateTask (baseActivity, upIntent)) {
android.support.v4.app.TaskStackBuilder.create (baseActivity)
.addNextIntentWithParentStack (upIntent)
.startActivities ();
} else {
NavUtils.navigateUpTo (baseActivity, upIntent);
}
} else {
NavUtils.navigateUpFromSameTask (baseActivity);
}
}
Is there something I'm missing here?