Android许可证检查失败太多了,我做错了什么?

时间:2011-09-16 18:24:45

标签: java android android-lvl

我有一个使用Google许可服务的Android应用,我收到大约5%的新用户的定期电子邮件,抱怨许可检查失败。它开始影响我的销售。我到底做错了什么?

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 either 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;
    }
}

1 个答案:

答案 0 :(得分:2)

你没有做错任何事。我也有同样的问题,也有其他人。你可以做的并不多,但仍然:

  1. 打开一张Google支持票,告诉他们LVL的性能不理想并影响合法用户。
  2. 在“未许可”对话框中添加“重试”按钮。有时它只是一个短暂的网络故障,导致许可失败。
  3. 考虑在我们的对话框中留下Google的支持电子邮件,或者为用户添加其他方式将问题传达给其来源。
  4. 唯一有效的选项可能是:如果响应是针对永久性购买,则在将其存储在缓存中之前,手动增加从许可服务收到的GT时间戳的值。检查GT时间戳和VT时间戳之间的差异 - 如果它足够大(一周),则将另一个月甚至一年添加到GT。这个想法是,一旦用户通过了退款期限,您可以将他/她的许可证作为半永久性或永久性地在他/她的设备上使用。
  5. 希望这有帮助。