gpt4 book ai didi

android - 如何从在 android 中添加两次的 LocationManager 中删除 LocationListener?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:12:16 24 4
gpt4 key购买 nike

如果我将 this 添加为 LocationListener 两次,如下所示

manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,3,this);
manager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,3,this);

,如下所示只删除一次this就够了吗

manager.removeUpdates(this);

最佳答案

是的,删除 manager.removeUpdates(this); 就足够了。作为documentation说:

使用给定的 LocationListener 删除当前 Activity 的位置更新的任何当前注册。在此调用之后,此监听器将不再发生更新。

关于android - 如何从在 android 中添加两次的 LocationManager 中删除 LocationListener?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4485546/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com