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 fluent的在模拟压强时使用希望得到一些建议
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流
    • ¥15 Rstudio 保存代码闪退