Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle InAppBilling onPurchaseStateChange is never called
    text
    copied!<p>The call back method <code>onPurchaseStateChange</code> is never called. I did my own demo-app and also tried using the Google provided demo (Dungeons). </p> <p>I'm calling <code>requestPurchase(String productId, String payload)</code> from the <code>onClick</code> method.</p> <pre><code> @Override public void onClick(View view) { if(view == requestPurchaseButton) { mBillingService.requestPurchase("android.test.purchased", "10"); } } </code></pre> <p>The callback method <code>onRequestPurchaseResponse(Request, ResponseCode)</code> is called. The <code>responseCode</code> here gives the value <code>RESULT_OK</code>. So the request has been sent to the server.</p> <pre><code> @Override public void onRequestPurchaseResponse(RequestPurchase request, ResponseCode responseCode) { if(responseCode == ResponseCode.RESULT_OK) { Log.d("AJ", "onRequestPurchaseResponse.ResponeCode.RESULT_OK"); textView.append(request.mProductId + "\n"); } else if(responseCode == ResponseCode.RESULT_USER_CANCELED) { //doesn't go here } else { //doesn't go here } } </code></pre> <p>The javadoc for this method states </p> <blockquote> <p>This is called when we receive a response code from Market for a RequestPurchase request that we made. This is NOT used for any purchase state changes. All purchase state changes are received in onPurchaseStateChange(PurchaseState, String, int, long). This is used for reporting various errors, or if the user backed out and didn't purchase the item. The possible response codes are: RESULT_OK means that the order was sent successfully to the server. The onPurchaseStateChange() will be invoked later (with a purchase state of PURCHASED or CANCELED) when the order is charged or canceled. This response code can also happen if an order for a Market-managed item was already sent to the server. RESULT_USER_CANCELED means that the user didn't buy the item. RESULT_SERVICE_UNAVAILABLE means that we couldn't connect to the Android Market server (for example if the data connection is down). RESULT_BILLING_UNAVAILABLE means that in-app billing is not supported yet. RESULT_ITEM_UNAVAILABLE means that the item this app offered for sale does not exist (or is not published) in the server-side catalog. RESULT_ERROR is used for any other errors (such as a server error).</p> </blockquote> <p>But the callback method </p> <pre><code> @Override public void onPurchaseStateChange(PurchaseState purchaseState, String itemId, int quantity, long purchaseTime, String developerPayload) { Log.d("AJ", "onPurchaseStateChanged"); } </code></pre> <p>is never called.</p> <p>Am I missing something? The same thing is being done in Dungeons (Google provided demo) and the <code>onPurchaseStateChange</code> is not called. </p> <p>The <a href="http://developer.android.com/guide/market/billing/billing_testing.html" rel="nofollow">Test-InAppBilling</a> document shows that we must be able to reach Purchased state. But When I try, I see only </p> <blockquote> <p>android.test.purchased: sending purchase request.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload