我收到此异常的logcat我每次按时间Back
我的应用程序按钮:
活动已泄漏,最初这里必然ServiceConnection com.android.vending.licensing.LicenseChecker@471cc039
负责此泄漏中的代码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;
}
}
起初,我以为我可以忽略调用它,但我双重检查和我打电话mChecker.onDestroy();
在我的活动的onDestroy()
我还检查onDestroy()
在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的错误吗?