使用 Tasks.call(Callable),我可以取消它,并从任务中删除所有侦听器吗?
When use Tasks.call(Callable), can I cancel it, and remove all the listeners from the task?
推荐答案如果您需要一种随时删除所有Task中所有侦听器的方法,则必须记住以前添加的所有侦听器,然后将其全部删除手动.
If you need a way to remove all the listeners from any Task at any time, you will have to remember all the listeners you previously added, then remove them all manually.
如果您使用的是Android应用,则添加活动-作用域的监听器,当主机活动停止时(通过其 onStop()生命周期方法),它们将被自动删除.请注意,您必须将活动作为参数传递给 addOnCompleteListener().
If you're working with an Android app, and you add Activity-scoped listeners, they will be removed automatically when the host activity is stopped (goes through its onStop() lifecycle method). Note that you have to pass the activity as an argument to addOnCompleteListener().
更多推荐
Google Play服务Task API:可以取消任务吗
发布评论