我在我的项目中设计了 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(); 初始化后。
我该怎么办?