LicenseChecker checkAccess leaks ServiceConnection

后端 未结 4 920
遥遥无期
遥遥无期 2021-01-07 22:18

I am receiving this exception in LogCat every time I press the Back button in my app:

Activity has leaked ServiceConnection com.android

相关标签:
4条回答
  • 2021-01-07 22:40

    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.

    0 讨论(0)
  • 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();
        }
    
    0 讨论(0)
  • 2021-01-07 22:52

    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" />
    
    0 讨论(0)
  • 2021-01-07 23:00

    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.

    0 讨论(0)
提交回复
热议问题