【发布时间】:2015-06-25 22:28:58
【问题描述】:
我正在尝试将 paypal 作为付款方式集成到我的 android 应用程序中,但我因类似这样的错误而失败。
错误:(70, 5) 错误: 找不到合适的方法 startService(Intent,int) 方法 ContextWrapper.startService(Intent) 是 不适用(实际参数列表和形式参数列表的长度不同) 方法 Context.startService(Intent) 不适用(实际和 形式参数列表的长度不同)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pay);
actionBar = getActionBar();
ColorDrawable colorDrawable = new ColorDrawable(
Color.parseColor("#01bfff"));
actionBar.setBackgroundDrawable(colorDrawable);
btnPayPal = (Button) findViewById(R.id.btnPaypal);
//Intent get value
Intent intent = getIntent();
final String currency = intent.getStringExtra("CURRENCY");
int cost = intent.getIntExtra("COST", 0);
txtCurrency.setText(currency);
txtTotal.setText(String.valueOf(" " + cost));
btnPayPal.setOnClickListener(new OnClickListener() {
public void onClick (View v) {
Intent in = new Intent(this, PayPalService.class);
in.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
startService(intent,0);
}public void onBuyPressed(View pressed) {
PayPalPayment payment = new PayPalPayment(new BigDecimal("2"), "USD", "Total Ticket Price : ",
PayPalPayment.PAYMENT_INTENT_SALE);
Intent intnt = new Intent(this, PaymentActivity.class);
intnt.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
intnt.putExtra(PaymentActivity.EXTRA_PAYMENT, payment);
startActivityForResult(intnt, 0);
}
@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
Log.i("paymentExample", confirm.toJSONObject().toString(4));
} catch (JSONException e) {
Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
}
}
}
else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("paymentExample", "The user canceled.");
}
else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i("paymentExample", "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
}
}
});
它在
中返回预期public void onClick (View v) {
Intent in = new Intent(this, PayPalService.class);
in.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
startService(intent,0);
}
【问题讨论】:
标签: android android-intent paypal