Error: YouTubeService has leaked IntentReceiver ... Are you missing a call to unregisterReceiver()?(错误:YouTubeService 泄露了 IntentReceiver ...您是否错过了对 unregisterReceiver() 的调用?)
问题描述
我使用 YoutubeServie API 在我的 Android 应用程序中播放 youtube 视频.然而,当我退出我的活动时,我发现下面的崩溃日志显示,即使我的应用程序仍然有效.
I uses YoutubeServie API to play youtube video in my Android application. However when I exit my activity, I found the below crash log showing, even my App still works.
02-28 15:54:02.081 20374-20374/? E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver com.google.android.libraries.youtube.player.audiofocus.HeadsetPlugReceiver@a843e7c 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 com.google.android.libraries.youtube.player.audiofocus.HeadsetPlugReceiver@a843e7c that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:898)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:699)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1637)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1617)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1611)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:488)
at com.google.android.libraries.youtube.player.service.PlaybackService.<init>(PlaybackService.java:5034)
at com.google.android.libraries.youtube.player.PlayerInjector$12.create(PlayerInjector.java:1602)
at com.google.android.libraries.youtube.common.util.Lazy.get(Lazy.java:136)
at com.google.android.libraries.youtube.player.PlayerInjector.getPlaybackService(PlayerInjector.java:575)
at com.google.android.apps.youtube.api.ApiPlayer.moveToForeground(ApiPlayer.java:493)
at com.google.android.apps.youtube.api.ApiPlayer.<init>(ApiPlayer.java:150)
at com.google.android.apps.youtube.api.service.jar.ApiPlayerService.<init>(ApiPlayerService.java:131)
at com.google.android.apps.youtube.api.service.jar.ApiPlayerFactoryService$1.run(ApiPlayerFactoryService.java:86)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
02-28 15:54:02.088 20374-20374/? E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver com.google.android.libraries.youtube.player.audiofocus.AudioBecomingNoisyReceiver@379c216f 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 com.google.android.libraries.youtube.player.audiofocus.AudioBecomingNoisyReceiver@379c216f that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:898)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:699)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1637)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1617)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1611)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:488)
at com.google.android.libraries.youtube.player.service.PlaybackService.<init>(PlaybackService.java:4043)
at com.google.android.libraries.youtube.player.PlayerInjector$12.create(PlayerInjector.java:1602)
at com.google.android.libraries.youtube.common.util.Lazy.get(Lazy.java:136)
at com.google.android.libraries.youtube.player.PlayerInjector.getPlaybackService(PlayerInjector.java:575)
at com.google.android.apps.youtube.api.ApiPlayer.moveToForeground(ApiPlayer.java:493)
at com.google.android.apps.youtube.api.ApiPlayer.<init>(ApiPlayer.java:150)
at com.google.android.apps.youtube.api.service.jar.ApiPlayerService.<init>(ApiPlayerService.java:131)
at com.google.android.apps.youtube.api.service.jar.ApiPlayerFactoryService$1.run(ApiPlayerFactoryService.java:86)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
没有代码来自我的应用程序,但都在库中.我没有在我的代码中注册任何接收器,因此无法在我的片段中取消注册与 youtubeservice 一起使用的任何内容.
None of the code are from mine app, but all are in the library. I didn't register any receiver in my code, so can't unregister anything in my fragment that works with the youtubeservice.
我认为这个问题类似于 https://groups.google.com/forum/#!topic/android-developers/6gzpwkaRgoE 但没有给出答案.知道如何摆脱 youtube.api.service 的内部崩溃吗?
I think the issue is similar to https://groups.google.com/forum/#!topic/android-developers/6gzpwkaRgoE but no answer given. Any idea how to get rid of this internal crash of youtube.api.service?
推荐答案
即使你没有手动注册任何receiver,一个activity也可能注册它以在当前activity上以某种方式使用它.我认为您应该需要在 onPause() 上调用 unregisterReceiver() 方法.
Even if you do not manually register any receiver, an activity may register it to use it in some way on the current activity. I think you should need to call unregisterReceiver() method on onPause().
请注意,不保证会调用 onDestroy() 和 onStop().如果 onPause() 将被调用,则 Activity 不再在前台.
Please be aware that onDestroy() and onStop() are not guaranteed to be called. If onPause() will be called, then the Activity is no longer in the foreground.
OnStop():
当您不再对用户可见时调用.接下来您将收到 onRestart()、onDestroy() 或什么也没有,这取决于以后的用户活动.请注意,在调用 onPause() 方法后系统没有足够内存来保持 Activity 进程运行的低内存情况下,可能永远不会调用此方法.
Called when you are no longer visible to the user. You will next receive either onRestart(), onDestroy(), or nothing, depending on later user activity. Note that this method may never be called, in low memory situations where the system does not have enough memory to keep your activity's process running after its onPause() method is called.
有关更多信息,请访问以下链接:http://developer.android.com/reference/android/app/Activity.html#onStop%28%29
For more information, here's the link: http://developer.android.com/reference/android/app/Activity.html#onStop%28%29
还好我还找到了一些stackoverflow的项目,可以参考一下:
Fortunately, I also found some stackoverflow items that you can refer to:
- Activity 泄露了原本的 IntentReceiver在这里注册.你错过了对 unregisterReceiver() 的调用吗?
- 无法在我的 Android 应用中播放 youtube 视频一个>
- 您是否错过了对 unregisterReceiver() 的调用?在安卓中
我希望这会有所帮助.
这篇关于错误:YouTubeService 泄露了 IntentReceiver ...您是否错过了对 unregisterReceiver() 的调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:错误:YouTubeService 泄露了 IntentReceiver ...您是否错过了对 unregisterReceiver() 的调用?
基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01