android - initWithAppID 命令崩溃

标签 android paypal-sandbox

我是 Android 编程新手,尤其是 PayPal。我得到了一个任务是进行故障排除的应用程序 - 尽管是 Android 的新手,但在这一行崩溃了:

initWithAppID(this.getBaseContext(), appID, PayPal.ENV_SANDBOX);

首先,PayPal.ENV_SANDBOX 总是返回一个 0,我不确定它是否应该返回。其次,为什么总是在那里崩溃?我在网上搜索过原因,人们说是因为它没有完全初始化,这就是它失败的原因。现在我想知道如果我不能初始化这个库我需要做什么?

我正在使用 Eclipse IDE,在 Samsung Galaxy Tab Android 2.2 上进行测试

最佳答案

不知道这是否有帮助,但这是我在使用 PayPal.ENV_NONE(来自 https://github.com/phonegap/phonegap-plugins/blob/master/Android/PayPalPlugin/src/com/phonegap/plugin/mpl.java)进行测试时修复它的方法

PayPal pp = PayPal.getInstance();
if (pp == null) {
    try {
        pp = PayPal.initWithAppID(getApplicationContext(), "", PayPal.ENV_NONE);
    } catch (IllegalStateException e) {
        throw new RuntimeException(e);
    }
    pp.setShippingEnabled(false);
}

然后在创建按钮时:

PayPal pp = PayPal.getInstance();
CheckoutButton cb = pp.getCheckoutButton(
        getBaseContext(), 
        PayPal.BUTTON_194x37, 
        CheckoutButton.TEXT_PAY);
cb.setOnClickListener(new OnClickListener() {
    PayPalPayment payment = new PayPalPayment();
    // set subtotal etc ...
    Intent i = PayPal.getInstance().checkout(payment,getApplicationContext());
    startActivityForResult(i, 1);
});

希望能有所帮助

关于android - initWithAppID 命令崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7229264/

相关文章:

php - 保护 Paypal 支付信息变量?

google-app-engine - 如何在 python GAE 中从 PayPal 沙箱上线?

android - 当我在抽屉导航中使用带有发送 fragment 的 EditText 时,无法解析 fragment 中的方法 'findViewById'?

找不到 Android Gradle build-info.xml

android - 进度搜索栏通知未显示在 DownloadManager android 中

android - 如何将库(Actionbarhserlock)导入Android Studio

php - Paypal DPRA 禁用此商户消息以进行定期付款

Paypal 集成 - DoReferenceTransaction 和 DoAuthorization

android - 从 android PayPal sdk 中提取运输信息

java - 具有 NFC 功能的 GSM 手机 SIM 卡上的应用程序可连接到 Android 应用程序