Error: YouTubeService has leaked IntentReceiver … Are you missing a call to unregisterReceiver()?

前端 未结 1 827
野性不改
野性不改 2021-01-12 02:35

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.

1条回答
  •  攒了一身酷
    2021-01-12 03:26

    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().

    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():

    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

    Fortunately, I also found some stackoverflow items that you can refer to:

    • Activity has leaked IntentReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?
    • Unable to play youtube video in my android app
    • Are you missing a call to unregisterReceiver() ? in android

    I hope this will help.

    0 讨论(0)
提交回复
热议问题