IAB设置永远不会完成

时间:2013-10-06 22:49:23

标签: android in-app-billing android-billing

我已经搜了好几个小时试图解决这个问题。这是我到目前为止所做的。 (注意:我正在Android Studio中开发)

  1. 生成已签名的APK并上传到我的开发者控制台
  2. 制作应用内商品并将其激活
  3. 向我的清单添加了“结算”权限
  4. 广泛梳理Stack以尝试找到类似的问题。
  5. 基本上在logcat中我看到IABHelper开始设置,但从未在任何时候完成。 (听众永远不会得到回调)

    private static final String TAG = "Preference Activity";
    private static final String SKU_PRO = "desk.clock.pro.license";
    static final int RC_REQUEST = 10001;
    IabHelper mHelper;
    private boolean mIsPremium;
    private ArrayList<Preference> proSettings;
    IInAppBillingService mService;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
        bindService(new
                Intent("com.android.vending.billing.InAppBillingService.BIND"),
                mServiceConn, Context.BIND_AUTO_CREATE);
        proSettings = new ArrayList<Preference>();
        ActionBar b = getActionBar();
        b.setDisplayHomeAsUpEnabled(true);
        colorListener();
        textureListener();
        bgColorListener();
        onPresetListener();
        gradListener();
    
    
        String base64Key = "[my key from dev console]";
        bindService(new
                Intent("com.android.vending.billing.InAppBillingService.BIND"),
                mServiceConn, Context.BIND_AUTO_CREATE);
        mHelper = new IabHelper(this, base64Key);
        mHelper.enableDebugLogging(true);
        Log.d(TAG, "Starting setup");
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                if (!result.isSuccess()) {
                    // Oh noes, there was a problem.
                    Log.d(TAG, "Problem setting up In-app Billing: " + result);
                }
                Log.d(TAG, "Setting up success");
    
                Log.d(TAG, "querying inventory");
                mHelper.queryInventoryAsync(mGotInventoryListener);
                Log.d(TAG, "queried");
            }
        });
     IabHelper.QueryInventoryFinishedListener mGotInventoryListener
            = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result,
                                             Inventory inventory) {
    
            if (result.isFailure()) {
                // handle error here
                mIsPremium = false;
                disableProAndRevertSettings();
            }
            else {
                // does the user have the premium upgrade?
                mIsPremium = inventory.hasPurchase(SKU_PRO);
                if(mIsPremium) {
                    enableProSettings();
                }else {
                    disableProAndRevertSettings();
                }
            }
        }
    };
    ServiceConnection mServiceConn = new ServiceConnection() {
        @Override
        public void onServiceDisconnected(ComponentName name) {
            mService = null;
        }
    
        @Override
        public void onServiceConnected(ComponentName name,
                                       IBinder service) {
            mService = IInAppBillingService.Stub.asInterface(service);
        }
    };
     //rest of my activity
    

    我在我的logcat中得到了这一行,但在此之后却没有 10-06 15:46:44.485 20787-20787 / com.ssa.digitaldeskclock D / IabHelper:启动应用内结算设置。

1 个答案:

答案 0 :(得分:0)

通过获取IAB v3示例的所有util类的新版本来解决问题。我将所有新文件添加到我的util目录中,它完美无瑕。希望这可以帮助其他人。请参阅此链接以获取源 https://code.google.com/p/marketbilling/source/browse/v3/src/com/example/android/trivialdrivesample/util/IabHelper.java?r=5f6b7abfd0534acd5bfc7c14436f4500c99e0358