TheSquad
TheSquad

Reputation: 7506

StartForeground Bad notification Android 2.3.X

I'm having a bug report, for some android device with version 2.3.X :

android.app.RemoteServiceException: Bad notification for startForeground: java.lang.IllegalArgumentException

Here's my method...

final static int myID = 6785674;

public void putServiceToForeground() {
    if (notif == null) {
        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(MyApp.getAppContext())
        .setContentTitle("");
        notif = mBuilder.build();
        notif.icon = R.drawable.pixel;
    }
    startForeground(myID, notif);
}

Upvotes: 0

Views: 1926

Answers (1)

alex
alex

Reputation: 6409

Use the Builder to set the icon and also double check the documentation.

Required notification contents

A Notification object must contain the following:

  • A small icon, set by setSmallIcon()
  • A title, set by setContentTitle()
  • Detail text, set by setContentText()

Upvotes: 1

Related Questions