購入結果を確認するには、クラスBillingPurchaseObserverの別のメソッドを使用する必要があります。
@Override
public void onRequestPurchaseResponse(RequestPurchase request,
ResponseCode responseCode)
{
Log.d("TAG", "onRequestPurchaseResponse");
if (Consts.DEBUG)
{
Log.d("TAG", request.mProductId + ": " + responseCode);
}
if (responseCode == ResponseCode.RESULT_OK)
{
if (Consts.DEBUG)
{
Log.i("TAG", "purchase was successfully sent to server");
}
}
else if (responseCode == ResponseCode.RESULT_USER_CANCELED)
{
if (Consts.DEBUG)
{
Log.i("TAG", "user canceled purchase");
}
}
else
{
if (Consts.DEBUG)
{
Log.i("TAG", "purchase failed");
}
}
}
BillingService の purchaseStateChanged メソッドは変更しないでください。
/**
* Verifies that the data was signed with the given signature, and calls
* {@link ResponseHandler#purchaseResponse(Context, PurchaseState, String, String, long)}
* for each verified purchase.
*
* @param startId
* an identifier for the invocation instance of this service
* @param signedData
* the signed JSON string (signed, not encrypted)
* @param signature
* the signature for the data, signed with the private key
*/
private void purchaseStateChanged(int startId, String signedData,
String signature)
{
//...
}