我想在我的服务中有startForeground(int, id, notification)
,但为此我需要一个通知参数。对于过去的3小时里,我一直在试图创建一个通知,但它只是将不起作用:为什么不兼容的类型?
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("Notification title")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Notification text");
以下是错误:
我试图删除和取代我所有的进口,但没有任何作品。我怎样才能解决这个问题?
感谢,
Ruchir
谢谢,我会在7分钟内接受您的答案。我有一个关于'startForeground'的问题。什么是ID? –
@RuchirBaronia这是通知的唯一标识 –
@RuchirBaronia:这是与[notify()']一起使用的相同ID(http://developer.android.com/reference/android/app/NotificationManager.html #notify(INT,%20android.app.Notification))。您可以使用它来识别此“通知”,以防您需要在“通知”仍未处理时更新其内容。 – CommonsWare