【发布时间】:2014-07-07 16:46:16
【问题描述】:
我曾经阅读过this topic about NotificationCompat,我知道在 Gingerbread 及以下版本中需要 contentIntent。但是,我正在使用 android Gingerbread,我不想添加 PendingIntent。我应该怎么做才能收到正确的通知?
感谢您的帮助
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setAutoCancel(true);
builder.setContentTitle("Basic notification");
builder.setContentText(content);
builder.setSmallIcon(R.drawable.ic_launcher);
Notification notification = builder.build();
try {
NotificationManager manager = (NotificationManager) this
.getSystemService(NOTIFICATION_SERVICE);
manager.notify(8, notification);
} catch (Exception e) {
Log.i("Exception", e.getMessage());
}
例外:需要 contentIntent:pkg=com.example.notificationtutorial id=8 notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x10)
【问题讨论】:
标签: android