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

     

     

     

  • 相关阅读:
    Mysql语句
    数据库的介绍以及安装
    数据库的基本操作
    进程
    并发编程
    友链
    C/C++第十一届蓝桥杯省赛B组第二场比赛
    数据结构之【栈】+十进制转d进制(堆栈数组模拟)
    sort函数的用法与实验
    memset的实验
  • 原文地址:https://www.cnblogs.com/hpboy/p/3028085.html
Copyright © 2011-2022 走看看