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

     

     

     

  • 相关阅读:
    <!DOCTYPE html>的重要性!
    ibatis 常用标签
    string.match(RegExp) 与 RegExp.exec(string) 深入详解
    JavaScript RegExp.$1
    JavaScript RegExp.exec() 方法
    正则表达式常用符号说明
    正则表达式中/i,/g,/ig,/gi,/m的区别和含义
    JavaScript Math.floor() 方法
    JavaScript RegExp.test() 方法
    js日期格式化 扩展Date()
  • 原文地址:https://www.cnblogs.com/hpboy/p/3028085.html
Copyright © 2011-2022 走看看