AndroidアプリのチェックアウトアクティビティでPayPalボタンを機能させようとしています。しかし、NullPointerExceptionが発生しています。コードの1585行を参照しています。logcatの出力は次のとおりです。
03-22 21:27:28.659: W/dalvikvm(419): threadid=1: thread exiting with uncaught exception (group=0x40014760)
03-22 21:27:28.669: E/AndroidRuntime(419): FATAL EXCEPTION: main
03-22 21:27:28.669: E/AndroidRuntime(419): java.lang.NullPointerException
03-22 21:27:28.669: E/AndroidRuntime(419): at java.math.BigDecimal.<init>(BigDecimal.java:406)
03-22 21:27:28.669: E/AndroidRuntime(419): at com.fokrul.justdeals.ActivityTab$PaypalTask$1.onClick(ActivityTab.java:1585)
03-22 21:27:28.669: E/AndroidRuntime(419): at android.view.View.performClick(View.java:3110)
03-22 21:27:28.669: E/AndroidRuntime(419): at com.paypal.android.MEP.CheckoutButton.onClick(Unknown Source)
03-22 21:27:28.669: E/AndroidRuntime(419): at android.view.View.performClick(View.java:3110)
03-22 21:27:28.669: E/AndroidRuntime(419): at android.view.View$PerformClick.run(View.java:11934)
03-22 21:27:28.669: E/AndroidRuntime(419): at android.os.Handler.handleCallback(Handler.java:587)
03-22 21:27:28.669: E/AndroidRuntime(419): at android.os.Handler.dispatchMessage(Handler.java:92)
03-22 21:27:28.669: E/AndroidRuntime(419): at android.os.Looper.loop(Looper.java:132)
03-22 21:27:28.669: E/AndroidRuntime(419): at android.app.ActivityThread.main(ActivityThread.java:4123)
03-22 21:27:28.669: E/AndroidRuntime(419): at java.lang.reflect.Method.invokeNative(Native Method)
03-22 21:27:28.669: E/AndroidRuntime(419): at java.lang.reflect.Method.invoke(Method.java:491)
03-22 21:27:28.669: E/AndroidRuntime(419): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
03-22 21:27:28.669: E/AndroidRuntime(419): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
03-22 21:27:28.669: E/AndroidRuntime(419): at dalvik.system.NativeStart.main(Native Method)
PayPalアクティビティのOnclickメソッドのマイコードは次のとおりです。
class PaypalTask extends AsyncTask<Void, Void, Void> {
protected final char[] TOTAL_GBP = null;
public Void doInBackground(Void... arg0) {
ppObject = PayPal.initWithAppID(getBaseContext(), "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
btnPaypal = ppObject.getCheckoutButton(getApplicationContext(), PayPal.BUTTON_278x43, CheckoutButton.TEXT_PAY);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);
params.addRule(RelativeLayout.CENTER_VERTICAL);
btnPaypal.setLayoutParams(params);
rlPay.addView(btnPaypal);
if(utils.prefs.getBoolean("isLogged", false)) btnPaypal.setVisibility(View.VISIBLE); else btnPaypal.setVisibility(View.GONE);
btnPaypal.setOnClickListener(new OnClickListener(){
public void onClick(View view) {
// to check whether there are any books in the shopping cart
if(!cid.isEmpty()){
PayPalPayment payment = new PayPalPayment();
<<LINE 1585-->>>>> payment.setSubtotal(new BigDecimal(TOTAL_GBP));
payment.setCurrencyType("USD");
payment.setRecipient(Utils.PAYPAL_ACCOUNT);
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
Intent checkoutIntent = PayPal.getInstance().checkout(payment, getBaseContext());
startActivityForResult(checkoutIntent, 1);
}else{
utils.showToast("Your shopping cart is empty.");
// The PayPal button needs to be updated so that the user can click on it again.
btnPaypal.updateButton();
}
}
});
}
}
ここで何がうまくいかないのか考えてみませんか?