Android - java.lang.IllegalArgumentException: contentIntent required error caused by notification?

后端 未结 4 2250
北荒
北荒 2021-02-19 00:52

I have a service running that updates a notification in the notification bar when it recieves a message saying it has to be changed.

However I get the following error so

4条回答
  •  执笔经年
    2021-02-19 01:03

    I think this is because the Android OS Version

    The version 2.3 or lower,must set contentIntent,if not,you will get this Exception.

    In my project,I write like this:

     if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { 
         Intent intent = new Intent();
         PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, 0); 
         mNotification.contentIntent = contentIntent; 
     }
    

    Perhaps this could help you!

提交回复
热议问题