Android在应用程序内购买的问题 [英] Android In App Purchase Problems

查看:297
本文介绍了Android在应用程序内购买的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直使用静态响应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

  • Where does this Toast comes from. I couldn't find out it my code.
  • How can I override this Toast? Is it because of the Reserved product ID I used? Will it change once I use my own product Ids?
  • Which overridden function should be used know whether User has purchased or cancelled the request.

        @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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆