android - In App Billing crashed in API 23 -
i upgrading project api 23. app crashed on in-app billing api 23 works on api 22. when purchasehandler calls purchaseitem method, app crash on launchpurchaseflow method.
--------- beginning of crash 10-26 13:24:12.048 3031-3031/com.example.--- e/androidruntime: fatal exception: main process: com.example.---, pid: 3031 java.lang.illegalstateexception: iab helper not set up. can't perform operation: launchpurchaseflow @ com.android.vending.billing.util.iabhelper.checksetupdone(iabhelper.java:790) @ com.android.vending.billing.util.iabhelper.launchpurchaseflow(iabhelper.java:380) @ com.myqalam.inapppurchase.inapppurchasehandler.purchaseitem(inapppurchasehandler.java:31) @ com.myqalam.shalatindonesian.indexactivity.onmenuitemselected(indexactivity.java:95) @ com.android.internal.policy.phonewindow.onmenuitemselected(phonewindow.java:1151) @ com.android.internal.view.menu.menubuilder.dispatchmenuitemselected(menubuilder.java:761) @ com.android.internal.view.menu.menuitemimpl.invoke(menuitemimpl.java:152) @ com.android.internal.view.menu.menubuilder.performitemaction(menubuilder.java:904) @ com.android.internal.view.menu.menubuilder.performitemaction(menubuilder.java:894) @ com.android.internal.view.menu.iconmenuview.invokeitem(iconmenuview.java:468) @ com.android.internal.view.menu.iconmenuitemview.performclick(iconmenuitemview.java:129) @ android.view.view$performclick.run(view.java:21147) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616)
here code:
private context mcontext; private iabhelper billinhelper; public inapppurchasehandler(context context) { this.mcontext = context; billinhelper = new iabhelper(context, apppropertykey.base_64_key); toast.maketext(context.getapplicationcontext(),"iabhepler",toast.length_short).show(); } public void setonsetupcompletelistener(iabhelper.oniabsetupfinishedlistener listener){ billinhelper.startsetup(listener); } public void oniteminventoryasyn(iabhelper.queryinventoryfinishedlistener listener){ billinhelper.queryinventoryasync(listener); } public void purchaseitem(string sku,iabhelper.oniabpurchasefinishedlistener listener){ //if(billinhelper.issetupdone() && !billinhelper.isasyncinprogress())//change if (billinhelper!=null) billinhelper.launchpurchaseflow((activity) mcontext, sku, iabhelper.item_type_subs, 123, listener, ""); } public void onbillingactivityresult(int requestcode,int resultcode,intent data){ billinhelper.handleactivityresult(requestcode, resultcode, data); } public void disposebillinghelper() { if (billinhelper != null) { billinhelper.dispose(); } billinhelper = null; }
here code call function:
purchasehandler.purchaseitem(removeads.sku, new oniabpurchasefinishedlistener() { @override public void oniabpurchasefinished(iabresult result, purchase info) { if (result.issuccess()) { datamanager.setremoveads(true); toast.maketext(indexactivity.this, "ads removed.", toast.length_long).show(); refrshactivity(); } } });
i testing in-app billing on emulator cause crash. in-app billing wont test on emulator can tested :
- your real android device sign apk.
- another 1 android developer account upload sign apk test it.
Comments
Post a Comment