Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android billing-它说checkBillingSupported()已被弃用。我应该用什么来代替?_Android_Android Billing - Fatal编程技术网

Android billing-它说checkBillingSupported()已被弃用。我应该用什么来代替?

Android billing-它说checkBillingSupported()已被弃用。我应该用什么来代替?,android,android-billing,Android,Android Billing,Android文档中说这种方法已被弃用,但我看不出还有什么可以替代 基本上,我正在尝试这样做: if (mBillingService.requestPurchase(issueProductIdPsych, Consts.ITEM_TYPE_INAPP , null)) { // Check what happened? Did the person finish the purchase? did they cance? if(mBillingService.checkBil

Android文档中说这种方法已被弃用,但我看不出还有什么可以替代

基本上,我正在尝试这样做:

if (mBillingService.requestPurchase(issueProductIdPsych, Consts.ITEM_TYPE_INAPP ,  null)) 
{
   // Check what happened? Did the person finish the purchase? did they cance?
   if(mBillingService.checkBillingSupported(Consts.ITEM_TYPE_INAPP))
   {

   }                              

    //BillingHelper.requestPurchase(mContext, "android.test.purchased");
    // android.test.purchased or android.test.canceled or android.test.refunded
}
        buy.setOnClickListener(new Button.OnClickListener() 
        {  
           public void onClick(View v) 
           {
完成检查采购请求的结尾的正确方法是什么

我有这样一个购买按钮:

if (mBillingService.requestPurchase(issueProductIdPsych, Consts.ITEM_TYPE_INAPP ,  null)) 
{
   // Check what happened? Did the person finish the purchase? did they cance?
   if(mBillingService.checkBillingSupported(Consts.ITEM_TYPE_INAPP))
   {

   }                              

    //BillingHelper.requestPurchase(mContext, "android.test.purchased");
    // android.test.purchased or android.test.canceled or android.test.refunded
}
        buy.setOnClickListener(new Button.OnClickListener() 
        {  
           public void onClick(View v) 
           {
但我不太清楚下一步需要做什么


谢谢

希望用您需要的代码替换代码更简单,但显然谷歌描述了另一种选择。您必须实现MarketBillingService接口。所以这只是设计上的一个小小的调整。幸运的是,它们向您展示了如何实现这一点

转到主题“创建本地服务”。这些子类别包括:

  • 绑定到MarketBillingService
  • 向MarketBillingService发送计费请求
  • 验证是否支持应用内计费(检查是否支持计费)
  • 提出采购申请(申请采购)
为了解释所写的内容,我将在这里进行描述:

在类别中:“验证是否支持应用内计费(检查是否支持计费)” 他们要求您使用sendBillingRequest()。这允许您发送五种不同类型的计费请求:

  • CHECK_BILLING_SUPPORTED-验证Google Play应用程序是否支持应用内计费和可用的应用内计费API版本
  • 请求\采购-发送应用内项目的采购请求
  • 获取购买信息-检索购买或退款的交易信息
  • 确认通知-确认您已收到购买或退款的交易信息
  • RESTORE_TRANSACTIONS—检索托管采购的用户交易历史记录
表示在执行请求之前必须创建捆绑包

以下是如何执行确认的示例:

Bundle request = makeRequestBundle("CONFIRM_NOTIFICATIONS");
request.putStringArray(NOTIFY_IDS, mNotifyIds);
Bundle response = mService.sendBillingRequest(request);

检索响应后,检查捆绑包中的内容,将有三个关键项:响应代码、购买意图和请求ID。响应代码键为您提供请求的状态,请求ID键为您提供请求的唯一请求标识符。PURCHASE_INTENT键为您提供了一个PendingEvent,您可以使用它启动结账界面。

是的,我阅读了该文档,但不确定到底要做什么。您在创建捆绑包时完成了吗?在他们的地下城示例中,他们这样做就像我有代码一样。何时以及如何发送BillingRequest?谢谢是的,捆绑包被用作请求和响应,它使代码的使用和控制更加简单。响应将告诉您请求是否成功。抱歉,必须离开计算机。我仍然不确定这段代码将如何与我的设置一起工作。单击“购买”按钮后需要执行哪些步骤?我正试图切换到您建议的设计,但我有点卡住了……您有没有可能知道我的问题的答案:在设置完所有内容后,在“购买”按钮中,您将看到“绑定到MarketBillingService”。该文档告诉您在manifestfile中创建本地服务,将其绑定到MarketBillingService,检查是否连接,发送账单请求,接收账单请求,确认账单,并在确认后处理挂起事件。还有一种推荐的测试方法,因为您无法在模拟器上进行测试: