我正在尝试创建一个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);
}
错误在哪里? 谢谢你的帮助
答案 0 :(得分:0)
尝试添加builder.setContentIntent(pendingIntent);
builder.build();
之后{I}为我工作。