当前位置: 首页>>代码示例>>Java>>正文


Java AutoResolveHelper类代码示例

本文整理汇总了Java中com.google.android.gms.wallet.AutoResolveHelper的典型用法代码示例。如果您正苦于以下问题:Java AutoResolveHelper类的具体用法?Java AutoResolveHelper怎么用?Java AutoResolveHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AutoResolveHelper类属于com.google.android.gms.wallet包,在下文中一共展示了AutoResolveHelper类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onActivityResult

import com.google.android.gms.wallet.AutoResolveHelper; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case LOAD_PAYMENT_DATA_REQUEST_CODE:
            switch (resultCode) {
                case Activity.RESULT_OK:
                    PaymentData paymentData = PaymentData.getFromIntent(data);
                    handlePaymentSuccess(paymentData);
                    break;
                case Activity.RESULT_CANCELED:
                    // Nothing to here normally - the user simply cancelled without selecting a
                    // payment method.
                    break;
                case AutoResolveHelper.RESULT_ERROR:
                    Status status = AutoResolveHelper.getStatusFromIntent(data);
                    handleError(status.getStatusCode());
                    break;
            }

            // Re-enables the Pay with Google button.
            mPwgButton.setClickable(true);
            break;
    }
}
 
开发者ID:android-pay,项目名称:paymentsapi-quickstart,代码行数:25,代码来源:CheckoutActivity.java

示例2: requestPayment

import com.google.android.gms.wallet.AutoResolveHelper; //导入依赖的package包/类
public void requestPayment(View view) {
    // Disables the button to prevent multiple clicks.
    mPwgButton.setClickable(false);

    // The price provided to the API should include taxes and shipping.
    // This price is not displayed to the user.
    String price = PaymentsUtil.microsToString(mBikeItem.getPriceMicros() + mShippingCost);

    TransactionInfo transaction = PaymentsUtil.createTransaction(price);
    PaymentDataRequest request = PaymentsUtil.createPaymentDataRequest(transaction);
    Task<PaymentData> futurePaymentData = mPaymentsClient.loadPaymentData(request);

    // Since loadPaymentData may show the UI asking the user to select a payment method, we use
    // AutoResolveHelper to wait for the user interacting with it. Once completed,
    // onActivityResult will be called with the result.
    AutoResolveHelper.resolveTask(futurePaymentData, this, LOAD_PAYMENT_DATA_REQUEST_CODE);
}
 
开发者ID:android-pay,项目名称:paymentsapi-quickstart,代码行数:18,代码来源:CheckoutActivity.java

示例3: saveToAndroid

import com.google.android.gms.wallet.AutoResolveHelper; //导入依赖的package包/类
public void saveToAndroid(View view) {
    LoyaltyWalletObject wob = generateLoyaltyWalletObject();
    CreateWalletObjectsRequest request = new CreateWalletObjectsRequest(wob);
    Wallet.WalletOptions walletOptions = new Wallet.WalletOptions.Builder()
            .setTheme(WalletConstants.THEME_LIGHT)
            .setEnvironment(WalletConstants.ENVIRONMENT_PRODUCTION)
            .build();

    walletObjectsClient = Wallet.getWalletObjectsClient(this, walletOptions);
    Task<AutoResolvableVoidResult> task = walletObjectsClient.createWalletObjects(request);
    AutoResolveHelper.resolveTask(task, this, SAVE_TO_ANDROID);
}
 
开发者ID:android-pay,项目名称:s2ap-quickstart-android,代码行数:13,代码来源:MainActivity.java

示例4: onCreate

import com.google.android.gms.wallet.AutoResolveHelper; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_RECREATING)) {
        return;
    }

    PaymentsClient paymentsClient = Wallet.getPaymentsClient(this, new Wallet.WalletOptions.Builder()
            .setEnvironment(getIntent().getIntExtra(EXTRA_ENVIRONMENT, WalletConstants.ENVIRONMENT_TEST))
            .build());

    PaymentDataRequest request = getIntent().getParcelableExtra(EXTRA_PAYMENT_DATA_REQUEST);
    AutoResolveHelper.resolveTask(paymentsClient.loadPaymentData(request), this, REQUEST_CODE);
}
 
开发者ID:braintree,项目名称:braintree_android,代码行数:16,代码来源:GooglePaymentActivity.java

示例5: onActivityResult

import com.google.android.gms.wallet.AutoResolveHelper; //导入依赖的package包/类
static void onActivityResult(BraintreeFragment fragment, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        fragment.sendAnalyticsEvent("google-payment.authorized");
        tokenize(fragment, PaymentData.getFromIntent(data));
    } else if (resultCode == AutoResolveHelper.RESULT_ERROR) {
        fragment.sendAnalyticsEvent("google-payment.failed");

        fragment.postCallback(new GooglePaymentException("An error was encountered during the Google Payments " +
                "flow. See the status object in this exception for more details.",
                AutoResolveHelper.getStatusFromIntent(data)));
    } else if (resultCode == Activity.RESULT_CANCELED) {
        fragment.sendAnalyticsEvent("google-payment.canceled");
    }
}
 
开发者ID:braintree,项目名称:braintree_android,代码行数:15,代码来源:GooglePayment.java


注:本文中的com.google.android.gms.wallet.AutoResolveHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。