我正在尝试为具有按钮的服务发出前景通知,按下该按钮将结束服务。我已经创建了按钮,但我不知道如何使我的意图结束服务。
public Notification getNotification(String message) {
Intent intent = new Intent(serviceContext, NotificationGenerator.class);
PendingIntent pi = PendingIntent.getActivity(serviceContext, 0, intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(serviceContext)
.setContentTitle(message)
.setContentText(message)
.setSmallIcon(R.drawable.icon)
.setContentIntent(pi)
.addAction(R.drawable.remove_button,"End Service", endService);
Notification n = builder.build();
n.defaults = Notification.DEFAULT_ALL;
return n;
}
Intent endService = new Intent();
我应该将endService设置为什么?