0

I'm trying to make a foreground notification for a service that has a button that when presses, will end the service. I have created the button but I have no idea what to make my intent to end the service.

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();
What should I set endService to to do so?

mgild
  • 774
  • 6
  • 13

0 Answers0