为什么我的通知不会出现

时间:2012-01-05 15:22:10

标签: android

大家好我使用预先通知管理器这是代码

Notification note = new Notification();
    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notif);
    contentView.setImageViewResource(R.id.image, R.drawable.notif);
    contentView.setTextViewText(R.id.title, "Focused Crawling");
    contentView.setTextViewText(R.id.text, "Crawling In Progress....");
    note.contentView = contentView;

    Intent notificationIntent = new Intent(this, LoadingActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    note.contentIntent = contentIntent;
    note.vibrate = new long[] { 500L, 200L, 200L, 500L };
    note.sound = Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, "2");
    note.flags |= Notification.FLAG_NO_CLEAR;

    mgr.notify(1337, note);
    startForeground(1337, note);

为什么它没有出现在状态栏?

1 个答案:

答案 0 :(得分:17)

您没有为状态栏指定图标,这是必需的。 在代码中添加如下所示的行:

note.icon = R.drawable.youricon;

请参阅Creating a Notification