0

我正在尝试创建一个 JB 通知,但我无法让它显示,并且它不会在 logcat 中给出任何错误,只是它什么都不做。

我用来创建通知的代码如下

private void bigPictureNotification(){

    Notification.Builder builder;
    Notification notification;
    NotificationManager manager;

    Intent intent = new Intent(this, NotificationPendingIntent.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);

    //carica l'immagine
    Bitmap icon = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.androidworld);

    builder = new Notification.Builder(getApplicationContext());
    builder.setContentTitle("Titolo piccolo");
    builder.setContentText("Testo della notifica");
    builder.setSmallIcon(R.drawable.ic_stat_notifica);
    builder.setLargeIcon(icon);
    builder.addAction(R.drawable.ic_action_search, "Cerca", pendingIntent);
    builder.addAction(R.drawable.ic_stat_notifica, "AndroidWorld", pendingIntent);
    builder.addAction(R.drawable.ic_launcher, "Launcher", pendingIntent);
    builder.build();

    notification = new Notification.BigPictureStyle(builder).bigPicture(icon).build();
    //notification = builder.build();
    notification.flags = Notification.FLAG_AUTO_CANCEL;

    manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    manager.notify(0, notification);

}

错误在哪里?谢谢您的帮助

4

2 回答 2

0

我会删除对

builder.build() 

就在之前

notification = ...

因为 builder.build() 给你一个通知对象。试一试。

于 2012-11-19T19:05:05.123 回答
0

在我把它放进去之后,试着在为我工作builder.setContentIntent(pendingIntent);之前添加builder.build();

于 2012-11-01T04:28:21.277 回答