Youtube Api Crashed, YouTubeService has leaked IntentReceiver

前端 未结 1 2025
南方客
南方客 2021-01-13 18:57

I have built a native android app using YoutubeApi. Sometimes when I backpress from another activity to the activity with the youtubePlayer fragment (YouTubePlayerSupportFr

相关标签:
1条回答
  • 2021-01-13 19:21

    Youtube api documantation seem to cover the soloution: https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerFragment

    "The YouTubePlayer associated with this fragment will be released whenever its onDestroyView() method is called. You will therefore have to re-call initialize(String, YouTubePlayer.OnInitializedListener) whenever the activity associated with this fragment is recreated, even if the fragment instance is retained across activity re-creation by setting setRetainInstance(boolean)."

    Adding this line helped:

            frag.setRetainInstance(true);
    

    frag is the youtube fragment I used for the api.

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