2012-06-17 30 views
2

我遵循了在應用程序內結算的Android在發現示例代碼的支持:http://developer.android.com/guide/market/billing/billing_integrate.html的Android的應用程序內結算聲稱沒有使用示例代碼

我還集成了一些代碼到我的應用程序 - 並且執行了所有步驟適當包括簽署APK - 上傳,在應用產品列表等

出於某種原因,當創建我的應用程序在onCreate方法這些行:

Log.e("sc2","About to check if billing is supported"); 
    // Check if billing is supported. 
    ResponseHandler.register(mDungeonsPurchaseObserver); 
    if (!mBillingService.checkBillingSupported()) { 
    Log.e("sc2","failed check for billing supported"); 
     showDialog(DIALOG_CANNOT_CONNECT_ID); 
    } 

    if (!mBillingService.checkBillingSupported(Consts.ITEM_TYPE_SUBSCRIPTION)) { 
     Log.e("sc2","failed check for billing supported subscriptions"); 
     showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID); 
    } 
    Log.e("sc2","Finished checking if billing is supported"); 

無論是對話節目 - 這表明一切勢必correc適合市場計費服務。

但是在PurchaseObserver回調這些行:

private class SC2PurchaseObserver extends PurchaseObserver { 
    public SC2PurchaseObserver(Handler handler) { 
     super(UpgradesActivity.this, handler); 
    } 

    @Override 
    public void onBillingSupported(boolean supported, String type) { 
     if (Consts.DEBUG) { 
      Log.e("sc2", "supported: " + supported+":"+type); 
     } 
     if (type == null || type.equals(Consts.ITEM_TYPE_INAPP)) { 
      if (supported) { 
       restoreDatabase(); 
       mBuyButton.setEnabled(true); 
       mEditPayloadButton.setEnabled(true); 
      } else { 
       showDialog(DIALOG_BILLING_NOT_SUPPORTED_ID); 
      } 
     } else if (type.equals(Consts.ITEM_TYPE_SUBSCRIPTION)) { 
      mCatalogAdapter.setSubscriptionsSupported(supported); 
     } else { 
      showDialog(DIALOG_SUBSCRIPTIONS_NOT_SUPPORTED_ID); 
     } 
    } 

日誌消息顯示如下:

支持:假:空 支持:假的:潛艇

這表明Android的市場回調已經表示在應用帳單標準中,或訂閱已啓用....

可以有人p租約解釋了爲什麼第一次檢查可能沒有失敗 - 但回電消息顯示爲他們的做法!?

非常感謝

回答

13

下面的代碼我用於Simple InApp Billing/Payment,你也可以使用。

enter image description here

enter image description here

希望它幫助。

+0

我今晚會說這個 - 如果它能正常工作並幫助我確定爲什麼我的代碼不符合 - 您將獲得賞金獎勵! – RenegadeAndy

+0

分享錯誤日誌請 –

+3

如果您需要,請使用此https://github.com/robotmedia/AndroidBillingLibrary –

0

您是否在創建請求包時更改了BILLING_REQUEST_API_VERSION。下面的方法來自於示例項目

protected Bundle makeRequestBundle(String method) { 
     Bundle request = new Bundle(); 
     request.putString(Consts.BILLING_REQUEST_METHOD, method); 
     request.putInt(Consts.BILLING_REQUEST_API_VERSION, 2); 
     request.putString(Consts.BILLING_REQUEST_PACKAGE_NAME, getPackageName()); 
     return request; 
} 
相關問題