What's the best way to control an Android service from an app (and app UI)?
For personal use, I'm writing a class that overrides NotificationListenerService and performs some customization of notifications before they're displayed.
So far I've been able to build a basic app that displays a UI and also starts an overridden NotificationListenerService. It works ok.
I'd like to be able to at least enable and disable that NotificationListenerService, though, via the UI. And ideally I'd like to be able to enter other data (like a start and end time for the notification changes, perhaps, or some customizations for which apps have their notifications modified) in that UI as well, and then have the overridden NotificationListenerService work using those values.
Within the Android ecosystem, what's the best way to have the app/UI and the service communicate in order to achieve that? Right now even if I close that UI, the service keeps running (which is great... but to disable or end it I'll need to reach it somehow).
Sorry if the question is strange or seems basic - this is my first Android app and I'm basically writing it because I need this functionality, so many aspects of app design/structure are new to me.
question from:
https://stackoverflow.com/questions/65642097/best-way-to-control-notificationlistenerservice-via-android-app-ui 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…