下面是我的接收器,工作正常..在接收功能正在打击..我通过使用吐司证实了这一点。但为什么通知也没有工作。为什么notifation没有显示?
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Bundle extra = intent.getExtras();
String msg= extra.getString("message");
//Toast.makeText(getApplicationContext(), "Message received."+ msg,
// Toast.LENGTH_LONG).show();
NotificationManager mNotificationManager = (NotificationManager) getApplicationContext()
.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
RegisterActivity.this)
.setContentTitle("Notification From GCM")
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
mNotificationManager.notify(100, mBuilder.build());
}
};
我错过了什么?
为什么我需要待定的意图?我不想为通知设置任何操作..我只想显示通知 – 2014-10-12 09:47:33
@ Mr.Vicky尝试添加'.setSmallIcon(R.drawable.ic_stat_gcm)'并更改'ic_stat_gcm'与您的图标名称。请参阅编辑回答。 – 2014-10-12 09:48:25
是的,它现在工作 – 2014-10-12 09:56:18