SufficientlySecure / donations

Donations library for Android. Supports Google Play Store, Flattr, PayPal, and Bitcoin
Apache License 2.0
347 stars 91 forks source link

IllegalStateException on Google Play billing when started twice #29

Open arpitkh96 opened 8 years ago

arpitkh96 commented 8 years ago

As far as i know its not allowed to run multiple asynctask for google in app billing.But this library is creating new tasks if pressed donate button twice.Maybe it needs to check if a task is already running and react according to it.

12-20 22:29:20.860 8218-8218/? E/AndroidRuntime: java.lang.IllegalStateException: Can't start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress.
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.google.util.IabHelper.flagStartAsync(IabHelper.java:820)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.google.util.IabHelper.launchPurchaseFlow(IabHelper.java:374)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.DonationsFragment.donateGoogleOnClick(DonationsFragment.java:350)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at org.sufficientlysecure.donations.DonationsFragment$1.onClick(DonationsFragment.java:226)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.view.View.performClick(View.java:4785)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:19884)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:746)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5343)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
12-20 22:29:20.860 8218-8218/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)
AllanWang commented 8 years ago

I am currently also experiencing this issue. My older apps (which probably aren't using 2.4) are not.

03-05 02:26:29.933 10033-10033/com.pitchedapps.material.glass.free E/AndroidRuntime: FATAL EXCEPTION: main Process: com.pitchedapps.material.glass.free, PID: 10033 java.lang.IllegalStateException: Can't start async operation (launchPurchaseFlow) because another async operation(launchPurchaseFlow) is in progress. at org.sufficientlysecure.donations.google.util.IabHelper.flagStartAsync(IabHelper.java:821) at org.sufficientlysecure.donations.google.util.IabHelper.launchPurchaseFlow(IabHelper.java:375) at com.pitchedapps.material.glass.fragments.DonationsFragment.donateGoogleOnClick(DonationsFragment.java:359) at com.pitchedapps.material.glass.fragments.DonationsFragment$1.onClick(DonationsFragment.java:235) at android.view.View.performClick(View.java:5204) at android.view.View$PerformClick.run(View.java:21154) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:117)

mx1up commented 8 years ago

disable the button as soon as it's pressed

AllanWang commented 8 years ago

And if you want to press the button a second time?

mx1up commented 8 years ago

you can reenable the button as soon as the first transaction has finished (in onactivityresult)

dschuermann commented 8 years ago

Have you properly delegated the results like done in https://github.com/SufficientlySecure/donations/blob/master/example/src/main/java/org/sufficientlysecure/donations/example/DonationsActivity.java#L84 ?

AllanWang commented 8 years ago

Sorry, my bad. It seems like I didn't the on activity created part. All is working now for me

dschuermann commented 8 years ago

The README should be improved to describe the usage of the onActivityResult delegation.

btimofeev commented 7 years ago

I have same issue. My onActivityResult is the same as in example. My code is here https://github.com/btimofeev/UniPatcher/blob/master/app/src/google/java/org/emunix/unipatcher/ui/activity/DonateActivity.java

Android 6.0.1 Google Play Services 10.0.84

dschuermann commented 6 years ago

I added a better explanation to the README to pass through results to the fragment in onActivityResult. I don't know why other crashes still happen.