首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Service com.google.android.youtube.api.service.YouTubeService泄漏了IntentReceiver uds@5fa5135

Service com.google.android.youtube.api.service.YouTubeService泄漏了IntentReceiver uds@5fa5135
EN

Stack Overflow用户
提问于 2017-06-12 05:07:27
回答 1查看 828关注 0票数 1

每次我从后台堆栈中删除YouTubePlayerSupportFragment时,我都会在日志中得到以下错误:

代码语言:javascript
复制
06-12 02:08:46.937 8805-8805/ D/GA_DEBUG: Event_category:VideoContent-Portrait-This artist uses unique methods to paint his pottery action:play label:youtube {&el=youtube, &ec=VideoContent-Portrait-This artist uses unique methods to paint his pottery, &t=event, &ea=play, &cd6=online}
06-12 02:08:46.945 10194-10194/? E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver uds@5fa5135 that was originally registered here. Are you missing a call to unregisterReceiver()?                                                   
android.app.IntentReceiverLeaked: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver uds@5fa5135 that was originally registered here. Are you missing a call to unregisterReceiver()?
    at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:946)
    at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:742)
    at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1188)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1168)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1162)
    at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:555)
    at udq.<init>(SourceFile:21)
    at udx.get(SourceFile:9)
    at vkq.get(SourceFile:31)
    at aces.get(SourceFile:10)
    at hog.a(SourceFile:26)
    at hpb.a(SourceFile:883)
    at hnz.<init>(SourceFile:13)
    at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(SourceFile:60)
    at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerFactoryService$1.run(SourceFile:10)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:152)
    at android.app.ActivityThread.main(ActivityThread.java:5497)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-12 02:08:46.968 10194-10194/? E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver udp@a7bd896 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver udp@a7bd896 that was originally registered here. Are you missing a call to unregisterReceiver()?
   at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:946)
   at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:742)
   at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1188)
   at android.app.ContextImpl.registerReceiver(ContextImpl.java:1168)
   at android.app.ContextImpl.registerReceiver(ContextImpl.java:1162)
   at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:555)
   at vki.<init>(SourceFile:53)
   at vkq.get(SourceFile:32)
   at aces.get(SourceFile:10)
   at hog.a(SourceFile:26)
   at hpb.a(SourceFile:883)
   at hnz.<init>(SourceFile:13)
   at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(SourceFile:60)
   at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerFactoryService$1.run(SourceFile:10)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:152)
   at android.app.ActivityThread.main(ActivityThread.java:5497)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
06-12 02:08:47.015 8805-8805/I/ResourcesManager: isUpToDate /data/app/com.google.android.youtube-1/base.apk: true

我做错了什么?在删除片段之前,我确实将所有资源设置为null,并在播放器实例上调用了release(),但此日志仍然存在。

EN

回答 1

Stack Overflow用户

发布于 2018-06-10 02:56:24

在尝试了多种方式使用Youtube播放器片段后,在项目中,我们在回收器视图中显示视频列表,每个视频都可以在适当的位置播放(当然,一次播放一个)。

仅管理正确的生命周期(在将碎片从一个位置移到另一个位置时调用release )将只在您快速执行之前有效,如果您碰巧尝试同时播放两个视频,则会出现上述问题(即youtube sdk内部将泄漏消息队列中的某些触摸事件)

因此,我们不是为每个视频替换youtube片段,而是只创建片段的一个实例,并在应用程序中的所有位置重用它,如果活动生命周期事件(暂停/停止或保存的实例状态被调用),则我们释放片段,并在恢复时再次创建youtube片段的单个活动实例

这种方法实际上也解决了上述问题,https://issuetracker.google.com/issues/78370483

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44488780

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档