如何启动和停止 NotificationListener for Android 服务?
我想在特定时间启动服务,也想在特定时间停止服务。
这怎么可能?
(我问的是 NotificationListener 库。)
最佳答案
由于 NotificationListenerService 是一种服务,您可以像任何其他服务一样启动或停止它,例如
首先扩展 NotificationListenerService
public class NotificationListener extends NotificationListenerService {...}
并实现您需要的回调。 请确保按照描述编辑您的 list here
现在您可以通过调用来启动您的服务
startService(new Intent(com.example.servicedemo.NotificationListener));
(当然你必须用你自己的包名替换 com.example... :) )
停止调用
stopService(new Intent(...));
关于android - 启动和停止notificationlistener服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28885332/