gpt4 book ai didi

android - Activity MainActivity 泄露了原本绑定(bind)在这里的 ServiceConnection azu@42be3310

转载 作者:行者123 更新时间:2023-11-29 17:18:39 24 4
gpt4 key购买 nike

我无法摆脱这个错误信息

E/ActivityThread: Activity com.example.project.MainActivity has leaked ServiceConnection azu@42be3310 that was originally bound here android.app.ServiceConnectionLeaked: Activity com.example.project.MainActivity has leaked ServiceConnection azu@42be3310 that was originally bound here at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:979) at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:873) at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1690) at android.app.ContextImpl.bindService(ContextImpl.java:1673) at android.content.ContextWrapper.bindService(ContextWrapper.java:517) at bye.a(:com.google.android.gms.DynamiteModulesA:127) at bye.a(:com.google.android.gms.DynamiteModulesA:144) at pg.b(:com.google.android.gms.DynamiteModulesA:348) at pg.a(:com.google.android.gms.DynamiteModulesA:190) at il.a(:com.google.android.gms.DynamiteModulesA:5176) at im.run(:com.google.android.gms.DynamiteModulesA:1042) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841)

最佳答案

这通常是在关闭 Activity 时绑定(bind)服务的结果。我之前通过在 Activity 中保留一个 bool 值来解决它,该值跟踪服务是否已绑定(bind)。然后在 onDestroy 中检查 Service 是否仍然与 bool 实例变量绑定(bind),如果仍然绑定(bind),则解除绑定(bind)。

我还在 onResume 中对服务进行初始绑定(bind),同时检查以确保它尚未与我的 bool 实例变量绑定(bind),以防万一

关于android - Activity MainActivity 泄露了原本绑定(bind)在这里的 ServiceConnection azu@42be3310,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37617808/

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