首页 > 解决方案 > YouTubeService 泄露了 IntentReceiver

问题描述

我正在尝试将播放的 youtube 添加到应用程序。

版本:YouTubeAndroidPlayerApi-1.2.2

播放器在布局中添加为

    <fragment
        android:id="@+id/youtube_video_fragment"
        android:name="com.views.video.YouTubePlayerSupportFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

此外,在销毁时释放播放器:

    @Override
    public void onDestroyView() {
    if (youTubePlayer != null) {
        youTubePlayer.release();
    }
    super.onDestroyView();
}

在后台删除父项时,我收到了这个 logcat 错误:

E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver acic@3ef7c23 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 acic@3ef7c23 that was originally registered here. Are you missing a call to unregisterReceiver()?
    at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:918)
    at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:719)
    at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1172)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1152)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1146)
    at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:554)
    at adso.<init>(SourceFile:65)
    at adtf.get(SourceFile:44)
    at anmy.get(SourceFile:10)
    at kqu.r(SourceFile:254)
    at acgu.get(SourceFile:9)
    at anmy.get(SourceFile:10)
    at kqw.a(SourceFile:10)
    at kpg.<init>(SourceFile:21)
    at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(SourceFile:52)
    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:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    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)

看起来 lib 在内部启动 YouTubeService 并且它注册接收器但没有取消注册它。有谁知道如何解决这个问题,或者只有带有修复的新版本库可以提供帮助?

标签: androidandroid-youtube-api

解决方案


推荐阅读