我想添加一个暂停按钮,如果可能的话,还会在通知中添加一个删除按钮。 像这样:
我该怎么做?
这是我的通知代码:
notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
context = getApplicationContext();
builder = new NotificationCompat.Builder(context)
.setContentTitle("Go!")
.setContentText("Timer set to " + waitingtime/1000 + " seconds")
.setTicker("Started!")
.setWhen(System.currentTimeMillis())
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(false)
.setOngoing(true)
.setSmallIcon(R.drawable.notlogosmall);
答案 0 :(得分:0)
您需要添加自定义视图,就像您在主屏幕小部件上显示视图一样:
在Notification Builder上查看此方法
使用布局中所需的两个按钮将其传递给RemoteView。
小例子:
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.custom_notification);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContent(remoteViews);