I'm a newbie Android "programmer" and I've tried to find the answer to this error without luck. There are some half answers but nothing that suggest what to do more exactly in my unique situation.
This error comes when closing a YoutubePlayer activity. It seems I should unregister a receiver, possibly in onPause( )...but how do I do that and maybe more important, which receiver should be unregistered?
Here is my logcat:
06-06 02:17:31.781 26887-26887/? E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver adez@e1c9513 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 adez@e1c9513 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:923)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:724)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1182)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1162)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1156)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:564)
at adex.<init>(SourceFile:18)
at adfe.get(SourceFile:15)
at aerr.get(SourceFile:46)
at aoqy.get(SourceFile:11)
at lad.h(SourceFile:148)
at addo.get(SourceFile:9)
at aoqy.get(SourceFile:11)
at laf.a(SourceFile:7)
at kyp.<init>(SourceFile:10)
at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(SourceFile:48)
at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerFactoryService$1.run(SourceFile:4)
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:5441)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)
Adding some code. Trying to keep it short. Activity:
public class VideoActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener, EasyPermissions.PermissionCallbacks {
This is what I have in onCreate():
youTubeView.initialize("@string/ytkey", this);
...and this is what I have regarding the YoutubePlayer:
@Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored) {
if (!wasRestored) {
player.loadVideo(userVideo.getYtId());
//player.setFullscreen(true);
}
}
@Override
public void onInitializationFailure(Provider provider, YouTubeInitializationResult errorReason) {
if (errorReason.isUserRecoverableError()) {
errorReason.getErrorDialog(this, RECOVERY_REQUEST).show();
} else {
String error = String.format(getString(R.string.player_error), errorReason.toString());
Toast.makeText(this, error, Toast.LENGTH_LONG).show();
}
}
protected Provider getYouTubePlayerProvider() {
return youTubeView;
}