I have the youtubeview in a fragment. When user clicks fullscreen button, it opens new activity with new youtubeview that's fullscreen. Pressing back and going to previous screen with the minimized youtubeview causes this error.
Activity com.livexlive.activities.FullscreenVideoActivity has leaked IntentReceiver com.pierfrancescosoffritti.youtubeplayer.utils.NetworkReceiver@cc726fe that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.livexlive.activities.FullscreenVideoActivity has leaked IntentReceiver com.pierfrancescosoffritti.youtubeplayer.utils.NetworkReceiver@cc726fe that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1355)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1120)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1428)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1401)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1389)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:622)
at com.pierfrancescosoffritti.youtubeplayer.player.YouTubePlayerView.initialize(YouTubePlayerView.java:77)
at com.livexlive.fragments.YoutubeStreamFragment$6.onComplete(YoutubeStreamFragment.java:305)
at com.livexlive.network_layer.MediaContentService$4.onResponse(MediaContentService.java:197)
at com.livexlive.network_layer.MediaContentService$4.onResponse(MediaContentService.java:190)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:83)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:106)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
The line of code that triggered this error is:
youTubePlayerView.initialize(new YouTubePlayerInitListener() {
@Override
public void onInitSuccess(final YouTubePlayer initializedYouTubePlayer) {
});
Fixed by adding the following code to my Youtube Fragment
@Override
public void onDestroy() {
super.onDestroy();
youTubePlayerView.release();
}
Hi, as you can read here, you could also add the YouTubePlayerView as an observer of your Activity/Fragment lifecycle. That's my preferred way of doing this.
Most helpful comment
Hi, as you can read here, you could also add the YouTubePlayerView as an observer of your Activity/Fragment lifecycle. That's my preferred way of doing this.