The Android application has created a service that periodically checks data on the Internet. Suppose it is up and running. As soon as the verified data changes, a corresponding notification will appear on the smartphone. The notification contains a title, text and two buttons. By pressing the first button opens the application. That's the question: how do you click on the second button to stop the service (stopService)?
1 answer
Here so try
stopService(new Intent(context, YourService.class)); - onein setAction (), pass some string, such as "STOP_SERVICE" in onReceive (), get this: String action = intent.getAction (). Then check that for action and call the appropriate logic - Android Android
- @ Vladimir attach a code to the question to make it clearer - Android Android
- Thank you, did as you described in the first comment. It helped. True, I had to study the topic of Receivers and PendingIntent. - Vladimir
- @ Vladimir Well, you see, it will be a plus =) - Android Android
|