2 xiaozj886 xiaozj886 于 2014.08.18 18:25 提问

PendingIntent.getActivity 无法跳转到activity?

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_launcher, "新消息", System.currentTimeMillis());
//采用默认声音
notification.defaults |= Notification.DEFAULT_SOUND;
//使用默认的灯光
notification.defaults |= Notification.DEFAULT_LIGHTS;
//通知被点击后,自动消失
notification.flags |= Notification.FLAG_AUTO_CANCEL;
//点击'Clear'时,不清楚该通知(QQ的通知无法清除,就是用的这个)
notification.flags |= Notification.FLAG_NO_CLEAR;
// 点击清除按钮不会清除消息通知,可以用来表示在正在运行
notification.flags |= Notification.FLAG_ONGOING_EVENT;
Intent appIntent = new Intent(context, EventActivity.class);
appIntent.addCategory(Intent.CATEGORY_LAUNCHER);
appIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, appIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// notification.setLatestEventInfo(context, title, desc, contentIntent);
notification.setLatestEventInfo(context, "新消息", "“伊斯兰国”攻势不停 美向库尔德人提供武器", contentIntent);
notificationManager.notify(messageNotificationID, notification);

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!