0

如何在应用程序启动时恢复付款状态。即为应用程序订阅集成贝宝,一旦应用程序启动,它会显示付款警报框,付款完成的应用程序将进入同一屏幕而没有警报框。如果我退出应用程序并再次启动(重新启动)然后我想获得付款状态,bcz 我想根据状态显示应用程序屏幕怎么做。这里添加 onActivity 结果

   @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 {

                    status_result=true;
                    Log.i("paymentExample", confirm.toJSONObject().toString(4));

                    // TODO: send 'confirm' to your server for verification.
                    // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                    // for more details.

                } 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_PAYMENT_INVALID) {
            Log.i("paymentExample", "An invalid payment was submitted. Please see the docs.");
        }
    }
4

2 回答 2

2

使用它来获取默认首选项:

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

使用它来保存一个值:

Editor edit = preferences.edit();
edit.putString("isPayed", "yes");
edit.apply(); 

这是检索值:preferences.getString("isPayed", "No");

于 2013-10-25T18:26:13.553 回答
0

你可以试试 SharedPreferences。每当付款活动完成时,将标志设置为 1。

例如。

int flag = entry.getInt("flag",0);
if(flag==0)
{
// Payment alert
// Payment finished
// editor.putInt("flag", ++flag);
// editor.commit();
}
else 
{
//Don't display the dialog
}

这样,当用户完成付款时,将标志设置为 1。

于 2013-10-25T18:26:11.607 回答