每当我按下我的应用程序中的LogCat按钮时,我都会在Back中收到这个异常:
活动泄露了最初绑定在这里的com.android.vending.licensing.LicenseChecker@471cc039 ServiceConnection
导致onCreate()中此泄漏的代码是:
mLicenseCheckerCallback = new MyLicenseCheckerCallback();
mChecker.checkAccess(mLicenseCheckerCallback);我该怎么处理这个漏洞?
我试图不将MyLicenseCheckerCallback分配给一个成员,我想,也许当活动进行onPause()时,对回调的引用是泄漏的原因:
mChecker.checkAccess(new MyLicenseCheckerCallback());但这并没有消除泄漏。
更新:感谢@zapl下面的评论,我查看了谷歌的LicenseChecker.java
/** Unbinds service if necessary and removes reference to it. */
private void cleanupService() {
if (mService != null) {
try {
mContext.unbindService(this);
} catch (IllegalArgumentException e) {
// Somehow we've already been unbound. This is a non-fatal error.
Log.e(TAG, "Unable to unbind from licensing service (already unbound)");
}
mService = null;
}
}起初,我认为我可能忽略了调用它,但是我在活动的onDestroy()中进行了反复检查,并调用了onDestroy()。
我还在LicenseChecker.java中检查了LicenseChecker.java,它调用了unbindService
/**
* Inform the library that the context is about to be destroyed, so that
* any open connections can be cleaned up.
* <p>
* Failure to call this method can result in a crash under certain
* circumstances, such as during screen rotation if an Activity requests
* the license check or when the user exits the application.
*/
public synchronized void onDestroy() {
cleanupService();
mHandler.getLooper().quit();
}那么到底是怎么回事?
这是LVL的窃听器吗?
发布于 2013-10-23 07:16:54
我只是遇到了同样的问题,通过您的更新和zapl的评论,我发现问题在于您正在使用的模拟器。
这个模拟器没有Google,LVL不能绑定到服务,保持连接打开,最后LVL不能用onDestroy调用关闭它。
使用Google而不是Androidx.x创建一个新的AVD,如果在使用创建新的AVD下载时找不到目标下拉列表中的Google,那么就在那里尝试一下。
发布于 2012-12-15 13:19:58
我也遇到了同样的问题,后来我知道我没有添加安卓许可com.android.vending.CHECK_LICENSE。在纠正了这个问题之后,我的问题现在解决了。尝试添加这一行您的android清单
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />发布于 2012-10-01 21:35:58
刚把
mChecker.onDestroy();在声明和使用onDestroy的活动的mChecker方法上。
而谷歌在LicenceChecker中的代码如下所示:
public synchronized void onDestroy() {
cleanupService();
mHandler.getLooper().quit();
}https://stackoverflow.com/questions/11992859
复制相似问题