libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
225 stars 82 forks source link

IAP: gdx-pay successfully instantiated. #25

Closed NaN8 closed 9 years ago

NaN8 commented 9 years ago

Dear all,

I do not know if I am doing anything wrong, gdx-pay seems to work very well the only thing is when I hit the back button on android, the following log keeps appearing "IAP: gdx-pay successfully instantiated." infinitly... and if I get back to my game the phone completly freeze. It seems that gdx-pay instantiation is called in a loop.... (via reflection??) .

noblemaster commented 9 years ago

Where in your code do you initialize IAP, a.k.a. do you call PurchaseSystem?

NaN8 commented 9 years ago

Hi Noblemaster!

IAP is initalized once in a class derived from ApplicationListener. PurchaseSystem is called yes. Actually the problem arise after I call purchase and after handlepurhase is called back. If I the delete the GDX.app.postRunnable call in handlepurcahse like in "PayTest.java", the problem is solved. Why PurchaseSystem is disposed in handlepurchase and why in a Runnable? @Override public void handlePurchase (Transaction transaction) { message(" - purchased: " + transaction.getIdentifier() + "\n");

                // dispose the purchase system
                Gdx.app.postRunnable(new Runnable() {
                    @Override
                    public void run () {
                        message(" - disposing the purchase manager.\n");
                        PurchaseSystem.dispose();
                        message("Testing InApp System: COMPLETED\n");
                    }
                });
            }

Thank you

noblemaster commented 9 years ago

I see! Yes, don't use postRunnable; that's only for the test (otherwise the test wouldn't work). I guess I was too lazy to write a proper test-case with GUI (sorry). You also won't need the other postRunnable(...) that are in the test either. Directly call the different methods in the PurchaseSystem and simply ignore all the postRunnable.

NaN8 commented 9 years ago

Great! Thank you Noblemaster!