Google Play服务Task API:可以取消任务吗

编程入门 行业动态 更新时间:2024-10-26 04:30:20
本文介绍了Google Play服务Task API:可以取消任务吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用 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:可以取消任务吗

本文发布于:2023-11-12 21:42:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582603.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Play   Google   API   Task

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!