zoukankan      html  css  js  c++  java
  • [BUG记录]java.lang.IllegalArgumentException: contentIntent required

    今天遇到一个异常,在notificationManager.notify的时候发生java.lang.IllegalArgumentException: contentIntent required,原因是我个没有设置contentIntent。

    以前一直在4.0的机子上跑是没有问题的,在2.3、2.2上就会出现异常。

    所以还是要设置contentIntent,只是Intents设置不同的动作,contentIntent不可以设为空!!!

    例如:

     

            NotificationManager mNotifMgr = (NotificationManager)cn.getSystemService(Context.NOTIFICATION_SERVICE); 
            CharSequence title = cn.getString(R.string.app_name);
            Notification notify = new Notification(R.drawable.ic_launcher, message, System.currentTimeMillis());
            notify.flags |= Notification.FLAG_AUTO_CANCEL;
            
            //跳转的页面,且设置如果当前已经打开了,就是用当前这个。//FLAG_UPDATE_CURRENT 
            //Intent notifyIntent = new Intent(this, cn.getClass());
            //notifyIntent.addFlags(android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP);
            //notifyIntent.addFlags(android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            PendingIntent pendingintent = PendingIntent.getActivity(cn, 0, new Intent(), PendingIntent.FLAG_CANCEL_CURRENT);
            notify.setLatestEventInfo(cn, title, message, pendingintent);
            mNotifMgr.notify(notifyId, notify);

     

     

     

  • 相关阅读:
    (40)C#windows服务控制
    (6)C#事务处理
    (1)sqlite基础
    bzoj 2456 mode
    bzoj 2763 [JLOI2011]飞行路线
    bzoj1010[HNOI2008] 玩具装箱toy
    bzoj1034 [ZJOI2008]泡泡堂BNB
    [bzoj1059] [ZJOI2007] 矩阵游戏 (二分图匹配)
    [bzoj1066] [SCOI2007] 蜥蜴
    bzoj1072 [SCOI2007]排列perm
  • 原文地址:https://www.cnblogs.com/hpboy/p/3028085.html
Copyright © 2011-2022 走看看