3

I am trying to use Android Marketing Licensing within an, as yet, unpublished app.

I have installed and integrated the LVL libraries using the ServerManagedPolicy.

The problem is that, without exception, LicenseCheckerCallback.dontAllow is called with the response 'RETRY' when the license check is run.

I've read through many posts on this subject and ...

  • the manifest file contains the CHECK_LICENSE permission
  • I am running exactly the same .apk file as I have uploaded to the developer account
  • I have added a test user to the developer account
  • The response is the same on an emulator running 2.2 and a device running 2.3
  • The response is the same whether logged in as the test or developer user
  • The response is the same whether I have selected LICENCED or NOT_LICENCED within the developer account
  • Although both emulator and device have an internet connection at all times, the response is actually the same when no connection is present
  • The code isn't obfuscated at the moment

My code is basically that provided by the documentation ...

String deviceId = Settings.Secure.getString(getContentResolver(),Settings.Secure.ANDROID_ID);

mLicenseCheckerCallback = new MyLicenseCheckerCallback();
mChecker = new LicenseChecker(
            this, new ServerManagedPolicy(this,
                    new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY);

mChecker.checkAccess(mLicenseCheckerCallback);

What options do I have left to get this working?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Jez
  • 61
  • 5
  • I had this same problem with apps submitted to Play Store with LVL, and it only occurred on 2.2, but not on 2.3.3 or 4.x. I read your question and noticed that the first context parameter into your LicenseChecker constructor was not the application context. I changed it to getApplicationContext like you did in your answer below, and it works now. – ubzack May 03 '12 at 17:43

1 Answers1

3

The answer turned out to be here ... Android Context.bindService always returns false and ServiceConnection object is never triggered

The license check was being called from a tab page, so the code should be ...

String deviceId = Settings.Secure.getString(getContentResolver(),Settings.Secure.ANDROID_ID);

mLicenseCheckerCallback = new MyLicenseCheckerCallback();
mChecker = new LicenseChecker(
        getApplicationContext(), new ServerManagedPolicy(this,
                new AESObfuscator(SALT, getPackageName(), deviceId)),
        BASE64_PUBLIC_KEY);

mChecker.checkAccess(mLicenseCheckerCallback);
Community
  • 1
  • 1
Jez
  • 61
  • 5