活动有一个最初这里势必泄露ServiceConnection com.google.android.youtube.player [英] Activity has leaked ServiceConnection com.google.android.youtube.player that was originally bound here

查看:1305
本文介绍了活动有一个最初这里势必泄露ServiceConnection com.google.android.youtube.player的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是一个与布局的活动 android.support.v4.view.ViewPager 我用来操纵标签导航。我有不同的标签不同片段。在我的第三个选项卡,我加载从我的YouTube帐户部分YouTube缩略图。

I'm using an Activity that has a layout with android.support.v4.view.ViewPager that I used to manipulate Tab navigation. I have different Fragments for different Tabs. On my third Tab, I'm loading some YouTube thumbnails from my YouTube account.

当我从应用程序加载应用程序(当我住在第一个选项卡)和preSS返回退出,它的存在没有任何问题。但是,当我浏览到第二个选项卡,并尝试preSS返回键,应用程序存在一个错误如下。

When I load the application (when I'm staying at the first Tab) and press Back to exit from the application, it exists without any issue. But when I navigate to second Tab and try to press Back button, app exists with an error as follow.

E/ActivityThread(7187): Activity package.name.ActivityName has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@41e5d180 that was originally bound here
E/ActivityThread(7187): android.app.ServiceConnectionLeaked: Activity package.name.ActivityName has leaked ServiceConnection com.google.android.youtube.player.internal.r$e@41e5d180 that was originally bound here

我添加了YouTube数据API V3到我的项目。

I've added YouTube Data API v3 to my project.

我怎样才能解决这个问题呢?
为什么从第二个选项卡,但不是在第一个选项卡?

How can I solve this issue? Why the error appears when exiting from second Tab but not in First Tab?

这是不是<一个重复的问题href=\"http://stackoverflow.com/questions/1992676/i-cant-get-rid-of-this-error-message-activity-app-name-has-leaked-servicecon\">this.

推荐答案

如果我猜对了,你出现在第二页时加载API,并且还再初始化YouTube的API。而不是提供您的活动作为上下文尝试提供应用环境的API。

If I guess it correctly, you load the api when the second page appears, and also then init the YouTube API. Instead of supplying your activity as the context try supplying the application context to the api.

这篇关于活动有一个最初这里势必泄露ServiceConnection com.google.android.youtube.player的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆