仅初始化一次 paypal
我在我的项目中设计了 PayPal 功能,如下所示:
public class MypaypalActivity extends Activity implements OnClickListener{
/** Called when the activity is 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);
}
这只可以正常工作一次。当我第二次按下 PayPal 按钮时,该应用程序崩溃了。 catlog中有一个错误是你初始化了PayPal两次,所以使用getInstance();初始化后。
为此我该怎么办?
I have designed PayPal functionality in my project like this:
public class MypaypalActivity extends Activity implements OnClickListener{
/** Called when the activity is 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 will work very correctly only once. When I press the PayPal button a second time then this application crashes. There is an error in catlog is that you initialized PayPal twice, so use getInstance(); after initialization.
What should I do for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嘿,这是我的问题的解决方案,我自己完成了这个。
谢谢大家...
Hey this is solution for my question, i have done this by myself.
thank you all...