ServiceConnection用youtube api泄露

时间:2017-09-20 07:21:07

标签: android youtube youtube-api android-youtube-api

首先,我在这里的一些线程中已经读过这个问题,我知道可以修复用应用程序上下文替换getActivity()。所有这些答案都来自几年前,现在我认为这不支持应用程序上下文,因为当我把应用程序上下文放在库的方法中时我得到一个错误我找不到任何可以放入的方法应用程序上下文。

当我创建tye YoutubeStandalonePlayer时,我正在这样做:

Intent intent = YouTubeStandalonePlayer.createVideoIntent(getActivity(), getResources().getString(google_maps_key), mPublication.getYoutubeCode());

如果我尝试放置应用程序上下文,我会收到错误,因为我正在传递应用程序上下文而不是活动,这是该方法正在等待的属性。

 Intent intent = YouTubeStandalonePlayer.createVideoIntent(ApplicationConfig.getAppContext(), getResources().getString(google_maps_key), mPublication.getYoutubeCode());

然后,我的问题是......如何使用YouTubeStandalonePlayer修复ServiceConnectionLeaked的问题:

android.app.ServiceConnectionLeaked: Activity com.buzinger.loycus.activity.HomeActivity has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@cbfec60 that was originally bound here

提前致谢

1 个答案:

答案 0 :(得分:3)

尝试使用我在本网站(https://androidadagnitio.wordpress.com/2017/03/09/activity-has-leaked-serviceconnection-com-google-android-youtube-player-internal-re391c339-that-was-originally-bound-here-error-solution/

中找到的解决方案

您需要添加此行以避免使用youtube api的ServiceConnectionLeaked。

Example=$(awk '/text to find/ && ! seen {print $1; seen=1}' < "$INPUT/Logs/${k}.txt")

所有代码:

 youTubeThumbnailLoader.release();
相关问题