Android: notification from BroadcastReceiver-ThrowExceptions

Exception or error:

I have an alarm manager that starts a broadcast receiver.
Here is my broadcast receiver:

public class AlarmBrodcastReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent arg1) {

    private void showNotification(Context context) {
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                new Intent(context, MyActivity.class), 0);

        NotificationCompat.Builder mBuilder =
                new NotificationCompat.Builder(context)
                .setContentTitle("My notification")
                .setContentText("Hello World!");
        NotificationManager mNotificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);


The broadcast starts in time, but there is no notification, only sound. Where is the text? What’s wrong? Is it because I’m using API 10 and the support library?

How to solve:

Oh, I found the problem. The problem is in .setSmallIcon(0)…When I set some real resource, its ok, notification appear…

Leave a Reply

Your email address will not be published. Required fields are marked *