Android许可库替代品

时间:2011-08-07 06:42:49

标签: android licensing

我目前正在其中一个应用中使用许可库。我的很多用户抱怨说,对话框告诉他们应用程序没有获得许可,当他们付费时。

错误的数据连接是问题:我自己甚至在wifi上得到它。我注意到我可以在飞机模式下打开rom管理器;

那么我的替代方案是什么?我想切换到一些不会打扰我的客户的东西,但仍保护我的应用程序。

我使用以下链接进行设置 http://www.droidforums.net/forum/android-app-developers/69899-market-license-easy-implementation-protect-your-apps.html

1 个答案:

答案 0 :(得分:3)

您仍然可以使用Google的库,但使用自定义的ServerManagedPolicy。默认的ServerManagedPolicy将向许可证服务器发出请求以检查用户是否获得许可,如果获得许可,它将在本地存储许可证的副本(通过首选项)。但是这个本地副本有一个到期日期,在它到期后,它将再次拨打许可证服务器进行重新检查。您需要做的就是修改此策略以使其具有更长的到期日期。首次运行应用程序时仍需要互联网连接,但很可能用户在购买应用程序后就会拥有互联网连接。

更改很简单,在此方法中,在if许可声明中,仅使用当前日期+一个月。目前,代码将使用许可证服务器发送的到期日期。

public void processServerResponse(LicenseResponse response, ResponseData rawData) {

    // Update retry counter
    if (response != LicenseResponse.RETRY) {
        setRetryCount(0);
    } else {
        setRetryCount(mRetryCount + 1);
    }

    if (response == LicenseResponse.LICENSED) {
        // Update server policy data
        Map<String, String> extras = decodeExtras(rawData.extra);
        mLastResponse = response;
        setValidityTimestamp(extras.get("VT")); //MAKE CHANGE HERE
        setRetryUntil(extras.get("GT"));
        setMaxRetries(extras.get("GR"));
    } else if (response == LicenseResponse.NOT_LICENSED) {
        // Clear out stale policy data
        setValidityTimestamp(DEFAULT_VALIDITY_TIMESTAMP);
        setRetryUntil(DEFAULT_RETRY_UNTIL);
        setMaxRetries(DEFAULT_MAX_RETRIES);
    }

    setLastResponse(response);
    mPreferences.commit();
}