Ruc*_*nia 0 java algorithm android object shared-libraries
我想startForeground(int, id, notification)在我的服务中,但为此,我需要一个通知参数.在过去的3个小时里,我一直在尝试创建该通知,但它不起作用:
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("Notification title")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Notification text");
Run Code Online (Sandbox Code Playgroud)
这是错误:
我试过删除并替换我的所有导入,但没有任何作用.我怎样才能解决这个问题?
谢谢,
Ruchir
您需要.build()在通知构建器上调用以获取通知:
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle("Notification title")
.setSmallIcon(R.mipmap.ic_launcher)
.setContentText("Notification text") // <---- NotificationCompat.Builder
.build(); // <--------
Run Code Online (Sandbox Code Playgroud)
你试图分配NotificationCompat.Builder一个Notification.
| 归档时间: |
|
| 查看次数: |
705 次 |
| 最近记录: |