gpt4 book ai didi

android - 错误 : YouTubeService has leaked IntentReceiver . .. 您是否错过了对 unregisterReceiver() 的调用?

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

我使用 YoutubeServie API 在我的 Android 应用程序中播放 youtube 视频。然而,当我退出 Activity 时,我发现显示了以下崩溃日志,即使我的应用程序仍然有效。

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)

所有代码都不是来 self 的应用程序,但都在库中。我没有在我的代码中注册任何接收器,因此无法在我的 fragment 中取消注册与 youtubeservice 一起使用的任何内容。

我认为这个问题类似于 https://groups.google.com/forum/#!topic/android-developers/6gzpwkaRgoE但没有给出答案。知道如何摆脱 youtube.api.service 的这种内部崩溃吗?

最佳答案

即使您没有手动注册任何接收器, Activity 也可以注册它以在当前 Activity 中以某种方式使用它。我认为您应该需要在 onPause() 上调用 unregisterReceiver() 方法。

请注意,不保证会调用 onDestroy() 和 onStop()。如果调用 onPause(),则 Activity 不再处于前台。

OnStop():

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.

For more information, here's the link: http://developer.android.com/reference/android/app/Activity.html#onStop%28%29

幸运的是,我还找到了一些stackoverflow的条目,你可以引用一下:

希望对您有所帮助。

关于android - 错误 : YouTubeService has leaked IntentReceiver . .. 您是否错过了对 unregisterReceiver() 的调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35678972/

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