Google Play服务Task API:可以取消任务吗 [英] Google Play services Task API: can a Task be cancelled

查看:41
本文介绍了Google Play服务Task API:可以取消任务吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用

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:可以取消任务吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆