Tôi đang cố triển khai trong thanh toán ứng dụng. Tôi đã sử dụng trivialdrivesample như nó được.Trong thiết lập thanh toán ứng dụng IAB thành công nhưng quaryInventory báo cáo IAB helper không được thiết lập
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// load game data
loadData();
String base64EncodedPublicKey = "my key";
// 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()) {
// Oh noes, there was a problem.
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);
}
});
}
Button purchaseB = (Button)findViewById(R.id.purchase_button);
if(purchaseB != null)
purchaseB.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
onUpgradeAppButtonClicked(null);
}
});
của nó làm việc một cách hoàn hảo và tôi có thể mua từ tài khoản thử nghiệm của tôi.
Nhưng vấn đề là tôi phải bình luận các dòng mã
// mHelper.queryInventoryAsync (mGotInventoryListener); SO Tôi không thể truy vấn khoảng không quảng cáo. Khi lồng tiếng tôi thấy biến số
// Is setup done?
boolean mSetupDone = false;
trong lớp IabHelper là sai và nó làm tăng ngoại lệ. Nhật ký chỉ sau khi nói rằng thiết lập thành công của nó nói rằng IAB helper không được thiết lập.
08-02 16:02:42.453: D/PackList(10346): Creating IAB helper.
08-02 16:02:42.453: D/PackList(10346): Starting setup.
08-02 16:02:42.468: D/IabHelper(10346): Starting in-app billing setup.
08-02 16:02:42.515: D/PackList(10346): Creating IAB helper.
08-02 16:02:42.539: D/IabHelper(10346): Billing service connected.
08-02 16:02:42.546: D/IabHelper(10346): Checking for in-app billing 3 support.
08-02 16:02:42.562: D/IabHelper(10346): In-app billing version 3 supported for com.xx
08-02 16:02:42.570: D/IabHelper(10346): Subscriptions AVAILABLE.
08-02 16:02:42.570: D/PackList(10346): Setup finished.
08-02 16:02:42.570: D/PackList(10346): Setup successful. Querying inventory.
08-02 16:02:42.578: E/IabHelper(10346): In-app billing error: Illegal state for operation (queryInventory): IAB helper is not set up.
Xem câu trả lời này: http://stackoverflow.com/questions/17944522/google-in-app-billing -causing-exception/17960318 # 17960318 – Carl
Xem trang này quá http://stackoverflow.com/a/13981478/2106820 –