我正在使用一个Service
并且我动态注册一个接收器,例如
private BroadcastReceiver yourCallReceiver;
yourCallReceiver = new CallReceiver();
// Registers the receiver so that your service will listen for broadcasts
registerReceiver(yourCallReceiver, theCallFilter);
并取消注册
@Override
public void onDestroy() {
super.onDestroy();
// Do not forget to unregister the receiver!!!
unregisterReceiver(yourCallReceiver);
}
但是我遇到问题,当我取消注册接收器时我需要关闭一些工作,但接收器没有onDestroy
方法。我怎样才能做到这一点?取消注册服务中的接收器时,如何停止某些第三方工作?这甚至可能吗?