Shutdown Foreground Service from tap notification action

Viewed 24

I have an app that uses a ForegroundService and a BroadcastReceiver. When the app is started, the ForegroundService is started too and the mandatory notification is sent to user to notify that such a service is running. Based on the App's way to work, Service needs to run indefinetely but i would like that the user could eventually shutdown the Service using a TapAction on this notification. Actually i achieved this result sending an explicit Intent to BroadcastReceiver and then on the onReceive() method send another explicit Intent to the ForegroundService to shut it down with stopService() method. I was wondering if there is a way to send directly an Intent from TapAction to ForegroundService considering that there is no onReceive() method on Service

0 Answers
Related