关于notification的一个小问题

使用noficaton报错如下:IllegalArgumentException: contentView required!

1 nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
2         long when = System.currentTimeMillis();
3         ntf = new Notification(ic,tickerText,when);
4         PendingIntent pt = PendingIntent.getActivity(this, 0, null, 0);
5         //ntf.setLatestEventInfo(getApplicationContext(), "QQ音乐", "正在下载...", pt);
6         nm.notify(R.string.app_name, ntf);

报错原因找到,是因为没有加注释这行,nofify之前,一定要让NotificationManager.setLatestEventInfo();

原文地址:https://www.cnblogs.com/bvin/p/2511136.html