Android在应用程序内购买的问题 [英] Android In App Purchase Problems
问题描述
我一直使用静态响应ID来实现应用程序内购买我的帐户 android.test.purchased
。现在,当购买项的吐司
弹出窗口说谢谢你,你的项目将在短期内出现。
I've implemented In App purchase in my account using static response id android.test.purchased
. Now when purchase the item a Toast
popups saying "Thank you. Your item will appear shortly."
我觉得到目前为止一切都完美的作品。
I think so far every thing works perfectly.
我的问题是
吐司
从何而来。我无法找到它在我的code。保留产品
我用的ID?它会改变一次我用我自己的产品ID?My problem is
Toast
comes from. I couldn't find out it my code.Reserved product ID
I used? Will it change once I use my own product Ids? @Override
public void onPurchaseStateChange(PurchaseState purchaseState, String itemId,
long purchaseTime, String developerPayload) {
if (purchaseState == PurchaseState.PURCHASED) {
// Is it here?
}
}
onPurchaseStateChange
下面是我的 onPurchaseStateChange
梅索德
@Override
public void onPurchaseStateChange(PurchaseState purchaseState, String itemId,
long purchaseTime, String developerPayload) {
if (Consts.DEBUG) {
Log.i(TAG, "onPurchaseStateChange() itemId: " + itemId + " " + purchaseState);
}
if (purchaseState == PurchaseState.PURCHASED) {
for (CatalogEntry e : CATALOG) {
if (e.sku.equals(itemId) &&
e.managed.equals(Managed.SUBSCRIPTION)) {
}
}
}
Toast.makeText(getApplicationContext(), "purchase failed", Toast.LENGTH_LONG).show();
}
任何帮助将大大AP preciated! :)谢谢!
Any help would be greatly appreciated! :) Thank you!
推荐答案
首先举杯来自于市场活动。这user1378730张贴在评论的链接解释它如何被删除。
Firstly the toast comes from the market place activity. The link that user1378730 posted in the comments explains about how it gets removed.
确定 onPurchaseStateChange
购买的结果,你所做的是正确的,purchaseState对象有几个枚举,你将能够检查。
Determining the outcome of the purchase in onPurchaseStateChange
as you have done is correct, the purchaseState object has several enumerations that you will be able to check.
我不建议在 onPurchaseStateChange
法进行界面交互,同时正在完成购买时可能被称为好几次。我跳出这个方法的一些自定义的在我的活动,决定如何做例如一个 onPurchaseCancel
和 onPurchaseSuccess
方法,可以告诉我们,如果它已经运行它的自我。这样做也可以让你在市场的互动从code流的其余部分分开,使得更容易调试。
I would not suggest performing interface interactions in the onPurchaseStateChange
method, as it may be called several times whilst the purchase is being completed. I jump out of that method to some custom ones on my activity to decide what to do e.g. a onPurchaseCancel
and onPurchaseSuccess
method that can tell if it's already run it's self. Doing this also allows you to separate the market interactions from the rest of your code flow, makes for easier debugging.
这篇关于Android在应用程序内购买的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!