LicenseChecker checkAccess leaks ServiceConnection

末鹿安然 提交于 2019-12-01 02:51:45

I just got the same problem, and with your update and zapl's comment I figured up that the problem is the emulator you are using.

This Emulators don't have the Google Play APIs, and the LVL can't bind to the service, leaving a connection open, at the end LVL can't close it with the onDestroy call.

Just create a new AVD using Google APIs instead of Android x.x and try your code there, if you don´t find the Google APIs in the Target pulldown when creating the new AVD download it with the Android SDK Manager.

I have also met the same problem later I got to know that i havn't added that android permission com.android.vending.CHECK_LICENSE . After correcting this my was problem is now solved. Try adding this line your android manifest

<uses-permission android:name="com.android.vending.CHECK_LICENSE" />

Just put

mChecker.onDestroy();

on your onDestroymethod of the activity that declares and uses the mChecker.

While Google's code in LicenceChecker looks like this:

  public synchronized void onDestroy() {
        cleanupService();
        mHandler.getLooper().quit();
    }

I don't know about google's LicenceChecker, but you should call StopService() before exit the Activity otherwise the service is still running and leaks memory.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!