0

我正在开发应用内计费模块。但是还是有一些问题。

1)我已经实现了许可证验证库(LVL)。一切都像示例应用程序一样完成并成功测试。但我收到错误消息:“免费应用程序不允许 CHECK_LICENSE 权限。” 将应用程序上传到市场时。我认为我需要实施 LVL,因为它与 billing-in-app 的相关安全问题。但似乎 LVL 仅适用于付费应用程序。我的应用程序是免费的,并且包含在应用程序模块中的计费。什么时候可以免费使用应用程序?

2)当付款成功处理时,我已经实现了如下的应用程序计费模块(将调用购买的InApp()方法):

private class MyAppPurchaseObserver extends PurchaseObserver {

   public MyAppPurchaseObserver(Handler handler) {
        super(MyAppPurchaseObserver.this, handler);
    }

    @Override
    public void onBillingSupported(boolean supported) {
        //Doing something
    }

    @Override
    public void onPurchaseStateChange(PurchaseState purchaseState, String itemId,
            int quantity, long purchaseTime, String developerPayload) {

        if(purchaseState == PurchaseState.PURCHASED) {
            purchasedInApp();
        }
    }

    @Override
    public void onRequestPurchaseResponse(RequestPurchase request,
            ResponseCode responseCode) {

        if (responseCode == ResponseCode.RESULT_OK) {
           //OK
        } else if (responseCode == ResponseCode.RESULT_USER_CANCELED) {
           //Canceled
        } else if(responseCode == ResponseCode.RESULT_BILLING_UNAVAILABLE ||
            responseCode == ResponseCode.RESULT_ITEM_UNAVAILABLE ||
            responseCode == ResponseCode.RESULT_SERVICE_UNAVAILABLE ||
            responseCode == ResponseCode.RESULT_DEVELOPER_ERROR) {
            //Error
        } else {
            //Fail
        }
    }

    @Override
    public void onRestoreTransactionsResponse(RestoreTransactions request,
            ResponseCode responseCode) {
        if (responseCode == ResponseCode.RESULT_OK) {
            //OK
        } else {
            //Error
        }
    }
}

以上实现的方法在主线程中调用?还是它是分开的线程?

提前致谢。

4

1 回答 1

0

据我所知,LVL 和应用内计费是相互独立的。他们唯一共享的是他们使用您的公钥进行验证。对于应用内计费,您的应用需要在获得com.android.vending.BILLING许可的情况下构建。

计费请求异步发送到手机上的另一个应用程序(Android Market 或 MyApps,具体取决于手机)。我不相信请求发出方法会阻塞,因此可以在 UI 线程或后台线程上运行它们。我不知道响应回调是否在 UI 线程上,但我对此表示怀疑(因为它们不适用于 LVL)。

于 2011-05-18T03:42:28.337 回答