I have an Android app that uses the Google Licensing service and I get regular emails from about 5% of new users complaining that the license check is failing. It is starting to affect my sales. What the heck am I doing wrong?
this.licenseCheckerCallback = new MyLicenseCheckerCallback();
String deviceId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
// Construct the LicenseChecker with a Policy.
this.licenseChecker = new LicenseChecker(
this, new ServerManagedPolicy(this,
new AESObfuscator(SALT, getPackageName(), deviceId)),
BASE64_PUBLIC_KEY // Your public licensing key.
);
this.checkLicense();
private void checkLicense() {
this.licenseChecker.checkAccess(this.licenseCheckerCallback);
}
private class MyLicenseCheckerCallback implements LicenseCheckerCallback {
public void allow() {
// Don't do anything, let the user work in peace.
}
public void dontAllow() {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// Should not allow access. In most cases, the app should assume
// the user has access unless it encounters this. If it does,
// the app should inform the user of their unlicensed ways
// and then ei开发者_开发知识库ther shut down the app or limit the user to a
// restricted set of features.
// In this example, we show a dialog that takes the user to Market.
showDialog(DIALOG_NO_LICENSE_ID);
MyActivity.this.dialogIdCurrentlyShown = DIALOG_NO_LICENSE_ID;
}
public void applicationError(ApplicationErrorCode errorCode) {
if (isFinishing()) {
// Don't update UI if Activity is finishing.
return;
}
// This is a polite way of saying the developer made a mistake
// while setting up or calling the license checker library.
// Please examine the error code and fix the error.
MyActivity.this.applicationErrorMessageForDialog = String.format(getString(R.string.application_error), errorCode);
showDialog(DIALOG_APPLICATION_ERROR_ID);
MyActivity.this.dialogIdCurrentlyShown = DIALOG_APPLICATION_ERROR_ID;
}
}
You aren't doing anything wrong. I am having the same problem, and other people too. And there's not much you could do, but still:
- Open a support ticket with Google telling them the performance of LVL suboptimal and is affecting legitimate users.
- Add a 'Retry' button to your 'Not licensed' dialog. Sometimes it's just a transient network failure which results in licensing failure.
- Consider leaving Google's support email in our dialog, or adding other means for a user to convey the problem to its source.
- And the only effective option, probably: manually increase the value of
GT
timestamp received from the licensing service before storing it in cache, if the response is for a permanent purchase. Check the difference between theGT
timestamp and theVT
timestamp - if it is large enough (a week), add another month or even a year toGT
. The idea is that once the user has passed the refund period, you can make his/her license semi-permanent or completely permanent on his/her device.
Hope this helps.
精彩评论