本文整理汇总了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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
}