JackyBower 2014-08-18 10:25
浏览 4039

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);

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料