关于通知栏Notification的使用,不多讲,这里说的很清楚http://www.cnblogs.com/zenfly/archive/2012/02/09/2343923.html

先说下我遇到的问题:

在应用关闭的时候,发送通知到通知栏,点击通知栏能正常跳转到我想要的页面,代码如下

1 Intent msgIntent = new Intent();
2  
3 msgIntent.addCategory(Intent.CATEGORY_LAUNCHER);
4                         msgIntent.setComponent(new ComponentName(context.getPackageName(), "com.test.FragmentActivity"));
5  
6 msgIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);// 关键的一步,设置启动模式
7  
8 UITools.showNotification(context, Notify.NORMAL, msgIntent, jsonBean.getMessageTitle());

在应用打开的情况下,发送通知,代码如下: 

1 Intent msgIntent = new Intent();
2  
3 msgIntent.setClass(context, FragmentActivity.class);
4  
5 msgIntent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);// 关键的一步,设置启动模式
6  
7 UITools.showNotification(context, Notify.NORMAL, msgIntent, jsonBean.getMessageTitle());



以上这段代码,出现了不能跳转的情况,于是,做了如下操作解决上述问题

1 <activity
2             android:name=".activity.FragmentActivity"
3             android:taskAffinity="" >
4         </activity>

相关文章: