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 使用C#,asp.net读取Excel文件并保存到Oracle数据库
    • ¥15 C# datagridview 单元格显示进度及值
    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配