Error:(38, 25) 错误: 找不到符号
符号: 方法 setLatestEventInfo(MyService,String,String,PendingIntent)
位置: 类型为Notification的变量 notification
解决:
如果编译的SDK版本在API23以上,就会出现这个问题,因为setLatestEventInfo方法在api23中被删掉了
在api4以上的版本用notification可以用support v4中的NotificationCompat.Builder。android文档中给了一个例子:
Notification noti = new Notification.Builder(mContext)
.setContentTitle("New mail from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_mail)
.setLargeIcon(aBitmap)
.build();
把上面"Notification.Builder"替换成"NotificationCompat.Builder"
alter+enter 把supportv4中的相关的库import进来
import android.support.v4.app.NotificationCompat;
于是代码编程了这样
Notification notification;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
notification = new Notificati