java - Initialize paypal only once -
i have designed paypal functionality in project this:
public class mypaypalactivity extends activity implements onclicklistener{ /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); linearlayout mlinlay= new linearlayout(this); setcontentview(r.layout.main); paypal pp = paypal.initwithappid(this, "app- 80w284485p519543t",paypal.env_sandbox); linearlayout layoutsimplepayment = new linearlayout(this); layoutsimplepayment.setlayoutparams(new layoutparams( layoutparams.wrap_content, layoutparams.wrap_content)); layoutsimplepayment.setorientation(linearlayout.vertical); checkoutbutton launchsimplepayment = pp.getcheckoutbutton(this, paypal.button_118x24, checkoutbutton.text_pay); launchsimplepayment.setonclicklistener( this); layoutsimplepayment.addview(launchsimplepayment); mlinlay.addview(layoutsimplepayment); setcontentview(mlinlay); }
this work correctly once. when press paypal button second time application crashes. there error in catlog initialized paypal twice, use getinstance(); after initialization.
what should this?
hey solution question, have done myself.
paypal pp = paypal.getinstance(); if (pp == null) { try { pp = paypal.initwithappid(this, "", paypal.env_none); } catch (illegalstateexception e) { throw new runtimeexception(e); } pp.setshippingenabled(false); }
thank all...
Comments
Post a Comment