Skip to content Skip to sidebar Skip to footer

Java.lang.illegalargumentexception: Contentintent Required

The full error also contains: android.app.RemoteServiceException: Bad notification for startForeground: I've read other similar posts here, tried their suggestions and read th

Solution 1:

In my case the Logcat debug was eloquent: " android.app.RemoteServiceException: Bad notification for startForeground:" Second line read: PendingIntent null!

In Android 4.x having a null PendingIntent is not a problem for starting foreground services, however in earlier Android versions it is.

So first of all check the debug log carefully (read all the lines and why not, post them here). If it is the same problem in your code I would check that the pendingIntent is not null. This could perhaps happen if mContext is null!

Have a look on the documentation for the setLatestEventInfo.

Here is how your code should look (if you are pushing these notifications from a service):

// The PendingIntent to launch our activity if the user selects this notification
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
            new Intent(this, LocalServiceActivities.Controller.class), 0);

    // Set the info for the views that show in the notification panel.
    notification.setLatestEventInfo(this, getText(R.string.local_service_label),
                   text, contentIntent);

Code was quoted from Android official documentation.

Also see this for a similar issue on StackOverflow.

Post a Comment for "Java.lang.illegalargumentexception: Contentintent Required"