我的通知代码:
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText("test")
.setAutoCancel(true)
.setTicker("Powiadomienie: test");
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
Intent ia = new Intent(this, ActivityA.class);
Intent ib = new Intent(this, ActivityB.class);
Intent ic = new Intent(this, ActivityC.class);
stackBuilder.addNextIntent(ia);
stackBuilder.addNextIntent(ib);
stackBuilder.addNextIntent(ic);
mBuilder.setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
mNotificationManager.notify(1, mBuilder.build());
活动顺序为:ActivityA -> ActivityB -> ActivityC
当显示 ActivityC 堆栈是从头开始构建时,就像在代码中一样。在后退按钮上显示 ActivityB 和 ActivityA。
视频显示发生了什么: http ://www.youtube.com/watch?v=YP_-KE-fuCg
显示最后一个活动 (ActivityA) 工具栏图标时显示标准图标,之后显示活动图标。此图标在 AndroidManifest.xml 中设置
<activity android:name="ActivityA" android:icon="@drawable/ic_launcher2"></activity>
<activity android:parentActivityName=".ActivityA" android:name="ActivityB" android:icon="@drawable/ic_launcher2">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ActivityA" />
</activity>
<activity android:parentActivityName=".ActivityB" android:name="ActivityC" android:icon="@drawable/ic_launcher2">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ActivityB" />
</activity>
我找不到如何解决它的答案。我不想闪烁图标。有人有这个问题的解决方案吗?
这是示例代码:https ://dl.dropboxusercontent.com/u/6099319/NotificationTest.zip