应用内计费:SampleApplication 并将数据存储在数据库中

发布于 2024-10-31 04:11:23 字数 623 浏览 1 评论 0原文

有人可以解释一下为什么 Android 的 示例应用程序 存储数据仅在 onRestoreTransactionsResponse 中而不在 onRequestPurchaseResponse 中存在于数据库中?

既然已经完成了,所以我不确定如何测试我的应用程序 - 如果我使用 standard产品 ID (android.test.purchased),则永远不会调用 onRestoreTransactionsResponse。 如果我使用自己的产品 ID - 我收到不允许购买的错误(我的应用程序已上传到 Android Market,但未发布;产品 ID 已发布)。

(我的应用程序仅支持一种产品 - “应用程序的付费版本”,也许我应该使用一些与示例应用程序不同的方法?)

Can somebody please explain me why Android's sample application stores data in the database only in onRestoreTransactionsResponse and not in onRequestPurchaseResponse?

Since it is done so I am not sure how to test my application - if I use standard product ID (android.test.purchased), then onRestoreTransactionsResponse is never called.
If I use my own product id - I am getting error that purchases are not allowed (my app is uploaded to Android Market, but not published; product id is published).

(My application will support one product only - 'paid version of application', probably I should use some different from the sample application approach?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鱼忆七猫命九 2024-11-07 04:11:23

说明可在示例应用程序随附的 PurchaseObserver 文件中找到 -
onRequestPurchaseResponse

/**
 * 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
 * {@link #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).

onRestoreTransactionsResponse 只是对我们的请求的响应(而不是购买状态):

/**
 * This is called when we receive a response code from Android Market for a
 * RestoreTransactions request that we made.  A response code of
 * RESULT_OK means that the request was successfully sent to the server.
 */

如果我调用 onRestoreTransactionsResponse,则 onRequestPurchaseResponse > 也称为。

The explanation is available at PurchaseObserver file coming with Sample Application -
onRequestPurchaseResponse:

/**
 * 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
 * {@link #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).

onRestoreTransactionsResponse is just about response to our request (not purchase status):

/**
 * This is called when we receive a response code from Android Market for a
 * RestoreTransactions request that we made.  A response code of
 * RESULT_OK means that the request was successfully sent to the server.
 */

If I call onRestoreTransactionsResponse, then onRequestPurchaseResponse is also called.

宛菡 2024-11-07 04:11:23

要知道的一件事是,为了能够测试您自己的项目,您必须创建您的应用程序的签名 apk 并将其手动安装在您的设备上(它对我来说就是这样,否则我会遇到与您相同的错误)

我希望有帮助!

One thing to know, to be able to test your own items you have to create a signed apk of you app and install it manually on your device (it was working for me that way, otherwise I had the same error you had)

I hope it helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文