1. <tfoot id='oxFGs'></tfoot><legend id='oxFGs'><style id='oxFGs'><dir id='oxFGs'><q id='oxFGs'></q></dir></style></legend>

      <small id='oxFGs'></small><noframes id='oxFGs'>

          <bdo id='oxFGs'></bdo><ul id='oxFGs'></ul>

        <i id='oxFGs'><tr id='oxFGs'><dt id='oxFGs'><q id='oxFGs'><span id='oxFGs'><b id='oxFGs'><form id='oxFGs'><ins id='oxFGs'></ins><ul id='oxFGs'></ul><sub id='oxFGs'></sub></form><legend id='oxFGs'></legend><bdo id='oxFGs'><pre id='oxFGs'><center id='oxFGs'></center></pre></bdo></b><th id='oxFGs'></th></span></q></dt></tr></i><div id='oxFGs'><tfoot id='oxFGs'></tfoot><dl id='oxFGs'><fieldset id='oxFGs'></fieldset></dl></div>

      1. 应用内计费不起作用:“未设置 IAB 助手"

        in-app billing doesn#39;t work: quot;IAB Helper is not set upquot;(应用内计费不起作用:“未设置 IAB 助手)
            <bdo id='rOwl5'></bdo><ul id='rOwl5'></ul>

            <i id='rOwl5'><tr id='rOwl5'><dt id='rOwl5'><q id='rOwl5'><span id='rOwl5'><b id='rOwl5'><form id='rOwl5'><ins id='rOwl5'></ins><ul id='rOwl5'></ul><sub id='rOwl5'></sub></form><legend id='rOwl5'></legend><bdo id='rOwl5'><pre id='rOwl5'><center id='rOwl5'></center></pre></bdo></b><th id='rOwl5'></th></span></q></dt></tr></i><div id='rOwl5'><tfoot id='rOwl5'></tfoot><dl id='rOwl5'><fieldset id='rOwl5'></fieldset></dl></div>
              <tbody id='rOwl5'></tbody>

            <tfoot id='rOwl5'></tfoot>

              <legend id='rOwl5'><style id='rOwl5'><dir id='rOwl5'><q id='rOwl5'></q></dir></style></legend>

              <small id='rOwl5'></small><noframes id='rOwl5'>

                1. 本文介绍了应用内计费不起作用:“未设置 IAB 助手"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试在我的应用中包含应用内计费并出于测试目的,基于应用内计费版本 3 的TrivialDrive"示例的整个过程(并将 IAB 文件的未修改版本实现为在演示的util"子目录中提供),但它对我不起作用 - 在 LogCat 上,就在应用程序因错误终止之前,它给出消息应用程序内计费错误:非法状态operation (launchPurchaseFlow): IAB Helper is not setup."(在 startRegistered() 函数被触发并给我 LOG 消息Register button clicked; launch purchase flow for upgrade."之后)...

                  I tried to include in-app billing in my app and for the purpose of testing, based the whole procedure on the "TrivialDrive" example for version 3 of in-app billing (and implementing the unmodified versions of the IAB files as supplied in the "util" subdirectory of the demo), but it doesn't work for me - on LogCat, just before the app terminates with an error, it gives the message "In-app billing error: Illegal state for operation (launchPurchaseFlow): IAB Helper is not set up." (right after the startRegistered() function has been fired and given me the LOG message "Register button clicked; launching purchase flow for upgrade.")...

                  知道这里出了什么问题吗?

                  Any idea what goes wrong here?

                  以下是我的代码的相关部分:

                  Here are the relevant parts of my code:

                  package com.mytest;
                  
                  (..)
                  import com.mytest.iab.IabHelper; // the originals from the demo example, unmodified
                  import com.mytest.iab.IabResult;
                  import com.mytest.iab.Inventory;
                  import com.mytest.iab.Purchase;
                  
                  public class Result3 extends Activity implements OnClickListener {
                  
                  private static final String TAG = "BillingService";
                  
                  private Context mContext;
                  
                  boolean mIsRegistered = false;
                  
                      // this has already been set up for my app at the publisher's console
                  static final String IS_REGISTERED = "myregistered";
                  
                  static final int RC_REQUEST = 10001;
                  
                  // The helper object
                  IabHelper mHelper; 
                  
                  /** Call when the activity is first created. */
                  @Override
                  public void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
                      setContentView(R.layout.result3);
                      mContext = this;
                  
                      String base64EncodedPublicKey = "[my public key]"; // (from publisher's console for my app)
                  
                      // Create the helper, passing it our context and the public key to verify signatures with
                      Log.d(TAG, "Creating IAB helper.");
                      mHelper = new IabHelper(this, base64EncodedPublicKey);
                  
                      // enable debug logging (for a production application, you should set this to false).
                      mHelper.enableDebugLogging(true);
                  
                      // Start setup. This is asynchronous and the specified listener
                      // will be called once setup completes.
                      Log.d(TAG, "Starting setup.");
                      mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
                          public void onIabSetupFinished(IabResult result) {
                              Log.d(TAG, "Setup finished.");
                  
                              if (!result.isSuccess()) {
                                  complain("Problem setting up in-app billing: " + result);
                                  return;
                              }
                  
                              // Hooray, IAB is fully set up. Now, let's get an inventory of stuff we own.
                              Log.d(TAG, "Setup successful. Querying inventory.");
                              mHelper.queryInventoryAsync(mGotInventoryListener);
                          }
                      });
                  
                     // Set the onClick listeners
                     findViewById(R.id.btnPurchase).setOnClickListener(this);
                  }
                  
                  // Listener that's called when we finish querying the items we own
                  IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
                      public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
                          Log.d(TAG, "Query inventory finished.");
                          if (result.isFailure()) {
                              complain("Failed to query inventory: " + result);
                              return;
                          }
                  
                          Log.d(TAG, "Query inventory was successful.");
                  
                          // Do we have the premium upgrade?
                          mIsRegistered = inventory.hasPurchase(IS_REGISTERED);
                          Log.d(TAG, "User is " + (mIsRegistered ? "REGISTERED" : "NOT REGISTERED"));
                  
                          setWaitScreen(false);
                          Log.d(TAG, "Initial inventory query finished; enabling main UI.");
                      }
                  };      
                  
                  // User clicked the "Register" button.
                  private void startRegistered() {
                      Log.d(TAG, "Register button clicked; launching purchase flow for upgrade.");
                      setWaitScreen(true);
                      mHelper.launchPurchaseFlow(this, IS_REGISTERED, RC_REQUEST, mPurchaseFinishedListener);
                  }
                  
                  @Override
                  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                      Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
                  
                      // Pass on the activity result to the helper for handling
                      if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
                          // not handled, so handle it ourselves (here's where you'd
                          // perform any handling of activity results not related to in-app billing..
                          super.onActivityResult(requestCode, resultCode, data);
                      }
                      else {
                          Log.d(TAG, "onActivityResult handled by IABUtil.");
                      }
                  }
                  
                  // Callback for when a purchase is finished
                  IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
                      public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
                          Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
                          if (result.isFailure()) {
                              // Oh noes!
                              complain("Error purchasing: " + result);
                              setWaitScreen(false);
                              return;
                          }
                  
                          Log.d(TAG, "Purchase successful.");
                  
                          if (purchase.getSku().equals(IS_REGISTERED)) {
                              Log.d(TAG, "User has registered..");
                              alert("Thank you.");
                              mIsRegistered = true;
                              setWaitScreen(false);
                          }
                      }
                  };
                  
                  // We're being destroyed. It's important to dispose of the helper here!
                  @Override
                  public void onDestroy() {
                      // very important:
                      Log.d(TAG, "Destroying helper.");
                      if (mHelper != null) mHelper.dispose();
                      mHelper = null;
                  }
                  
                  void complain(String message) {
                      Log.e(TAG, "**** Register Error: " + message);
                      alert("Error: " + message);
                  }
                  
                  void setWaitScreen(boolean set) {
                      // just a dummy for now
                  }
                  
                  void alert(String message) {
                      AlertDialog.Builder bld = new AlertDialog.Builder(this);
                      bld.setMessage(message);
                      bld.setNeutralButton("OK", null);
                      Log.d(TAG, "Showing alert dialog: " + message);
                      bld.create().show();
                  }
                  
                  @Override
                  public void onClick(View v) {
                      switch (v.getId()) {
                      case R.id.btnPurchase:
                          startRegistered();
                          break;
                      default:
                          break;
                      }
                  }
                  

                  }

                  这里有更多来自 Logcat 的行:

                  Here more lines from Logcat:

                  12-20 01:06:36.701: D/dalvikvm(299): GC_FOR_MALLOC freed 4262 objects / 308592 bytes in 84ms
                  12-20 01:06:36.701: D/webviewglue(299): nativeDestroy view: 0x2ea718
                  12-20 01:06:36.771: W/webcore(299): Can't get the viewWidth after the first layout
                  12-20 01:07:07.111: W/webcore(299): Can't get the viewWidth after the first layout
                  12-20 01:07:18.510: D/webviewglue(299): nativeDestroy view: 0x2dd458
                  12-20 01:07:18.510: D/dalvikvm(299): GC_FOR_MALLOC freed 6042 objects / 544504 bytes in 50ms
                  12-20 01:07:18.530: D/webviewglue(299): nativeDestroy view: 0x2ea8d0
                  12-20 01:07:18.660: D/BillingService(299): Creating IAB helper.
                  12-20 01:07:18.660: D/BillingService(299): Starting setup.
                  12-20 01:07:18.660: D/IabHelper(299): Starting in-app billing setup.
                  12-20 01:07:19.621: W/webcore(299): Can't get the viewWidth after the first layout
                  12-20 01:07:20.160: W/webcore(299): Can't get the viewWidth after the first layout
                  12-20 01:07:32.481: D/webviewglue(299): nativeDestroy view: 0x3f88e8
                  12-20 01:07:32.491: D/dalvikvm(299): GC_FOR_MALLOC freed 5798 objects / 513640 bytes in 50ms
                  12-20 01:07:32.511: D/BillingService(299): Register button clicked; launching purchase flow for upgrade.    
                  12-20 01:07:32.511: E/IabHelper(299): In-app billing error: Illegal state for operation (launchPurchaseFlow): IAB helper is not set up.
                  12-20 01:07:32.521: D/AndroidRuntime(299): Shutting down VM
                  12-20 01:07:32.521: W/dalvikvm(299): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
                  12-20 01:07:32.541: E/AndroidRuntime(299): FATAL EXCEPTION: main
                  12-20 01:07:32.541: E/AndroidRuntime(299): java.lang.IllegalStateException: IAB helper is not set up. Can't perform operation: launchPurchaseFlow
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at com.test_ed.iab.IabHelper.checkSetupDone(IabHelper.java:673)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at com.test_ed.iab.IabHelper.launchPurchaseFlow(IabHelper.java:315)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at com.test_ed.iab.IabHelper.launchPurchaseFlow(IabHelper.java:294)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at com.test_ed.Result3.startRegistered(Result3.java:157)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at com.test_ed.Result3.onClick(Result3.java:248)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at android.view.View.performClick(View.java:2408)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at android.view.View$PerformClick.run(View.java:8816)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at android.os.Handler.handleCallback(Handler.java:587)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at android.os.Handler.dispatchMessage(Handler.java:92)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at android.os.Looper.loop(Looper.java:123)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at android.app.ActivityThread.main(ActivityThread.java:4627)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at java.lang.reflect.Method.invokeNative(Native Method)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at java.lang.reflect.Method.invoke(Method.java:521)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
                  12-20 01:07:32.541: E/AndroidRuntime(299):  at dalvik.system.NativeStart.main(Native Method)
                  

                  推荐答案

                  在执行 purchaseFlow 函数时遇到了同样的问题.查看 Google 示例中的 Activity 类,特别是方法 protected void onActivityResult(int requestCode, int resultCode, Intent data).你可能忘了实现这个.此功能对于整个机制正常工作至关重要.

                  Had the same issue while executing purchaseFlow function. Take a look at Activity class in the Google's example and specifically at the method protected void onActivityResult(int requestCode, int resultCode, Intent data). You probably forgot to implement this one. This function is vital for the whole mechanism to work without a glitch.

                  @Override
                  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                      Log.i(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
                  
                      // Pass on the activity result to the helper for handling
                      if (!inappBillingHelper.handleActivityResult(requestCode, resultCode, data)) {
                          super.onActivityResult(requestCode, resultCode, data);
                      }
                      else {
                          Log.i(TAG, "onActivityResult handled by IABUtil.");
                      }
                  }
                  

                  此外,当您在手机上与您的 gmail 帐户关联的密码错误时也会存在此问题(今天发生在我身上).当然,所有的 Inapp 计费功能都应该在手机上进行测试,但我认为这是显而易见的.

                  Additionally the problem also exists when you have wrong password associated with your gmail account on your phone (this happened on me today). Of course all the Inapp billing features should be tested on the phone, but that I think is obvious.

                  这篇关于应用内计费不起作用:“未设置 IAB 助手"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Android - Is it possible to get install referrer programmatically(Android - 是否有可能以编程方式安装引荐来源网址)
                  How to sign an APK with more than one certificate?(如何使用多个证书签署 APK?)
                  versionCode vs versionName in Android Manifest(Android Manifest 中的 versionCode 与 versionName)
                  What does this Google Play APK publish error message mean?(这个 Google Play APK 发布错误消息是什么意思?)
                  Lost my keystore for uploaded app on android market(丢失了我在 android 市场上上传的应用程序的密钥库)
                  App on Google Play always shows quot;Updatequot; instead of open(Google Play 上的应用程序总是显示“更新;而不是打开)

                  <small id='OHira'></small><noframes id='OHira'>

                  <i id='OHira'><tr id='OHira'><dt id='OHira'><q id='OHira'><span id='OHira'><b id='OHira'><form id='OHira'><ins id='OHira'></ins><ul id='OHira'></ul><sub id='OHira'></sub></form><legend id='OHira'></legend><bdo id='OHira'><pre id='OHira'><center id='OHira'></center></pre></bdo></b><th id='OHira'></th></span></q></dt></tr></i><div id='OHira'><tfoot id='OHira'></tfoot><dl id='OHira'><fieldset id='OHira'></fieldset></dl></div>

                    <bdo id='OHira'></bdo><ul id='OHira'></ul>

                        <legend id='OHira'><style id='OHira'><dir id='OHira'><q id='OHira'></q></dir></style></legend>
                            <tbody id='OHira'></tbody>
                          <tfoot id='OHira'></tfoot>