Вопрос

I am trying to post a notification to the status bar without any intent, but nothing is happening? Am I missing anything? This code is inside my push notification receiver service.

notificationManager = (NotificationManager)
        this.getSystemService(Context.NOTIFICATION_SERVICE);

    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setContentTitle("Hello");
    builder.setContentTitle("This is my message");
    builder.setSmallIcon(R.drawable.ic_launcher);

    PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setFullScreenIntent(intent, true);

    notificationManager.notify(555, builder.build());
Это было полезно?

Решение

As mentioned in my comment, to create a notification for the notification manager, a small icon must also be provided.

Additionally, for developers targeting Android 2.2 and 2.3 as well, make sure to include a content Intent otherwise the app will crash.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top