【发布时间】:2013-11-09 03:03:44
【问题描述】:
我试图在没有任何意图的情况下向状态栏发布通知,但没有任何反应? 我错过了什么吗?此代码在我的推送通知接收器服务中。
notificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("Hello");
builder.setContentTitle("This is my message");
builder.setSmallIcon(R.drawable.ic_launcher);
PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
builder.setFullScreenIntent(intent, true);
notificationManager.notify(555, builder.build());
【问题讨论】:
-
您还需要small icon。此外,如果您希望此代码在 2.2 和 2.3 上运行,则需要一个 Intent 。
-
太棒了,请将其发布为答案,以便我接受
-
完成。很高兴看到您的问题已解决!
-
顺便提一下,您调用了两次 setContentTitle。
标签: android notifications notificationmanager