我正在开发一款移动Android应用。我正在使用Android Pay / Google Wallet的示例github应用程序。
我在产品结帐页面找到的一个问题如下。如果我使用以下API: https://developers.google.com/android/reference/com/google/android/gms/wallet/fragment/WalletFragmentStyle.LogoImageType
这会更改徽标(“Google Wallet”与“Android Pay”徽标)。 当使用值3作为 setMaskedWalletDetailsLogoImageType(3)的参数时,“更改”按钮不再起作用。
答案 0 :(得分:0)
**Android wallet is deprecated, in my case i did this;**
1. check id the device have NFC support (android pay use NFC)
2. if have nfc support use android pay, if dont have i use android wallet.
**First in the constant.java add:**
<br/>
//values to change buyapparence (android pay-wallet)
public static final int GOOGLE_WALLET_CLASSIC=1;
public static final int GOOGLE_WALLET_GRAYSCALE =2;
public static final int GOOGLE_WALLET_MONOCHROME=3;
public static final int ANDROID_PAY_DARK = 4;
public static final int ANDROID_PAY_LIGHT=5;
public static final int ANDROID_PAY_LIGHT_WITH_BORDER=6;
**Then in utils add the NFCcheck.java with this method;**
<code>
public boolean NFCsupport(){
boolean nfcSupport;
NfcManager manager = (NfcManager)mAppContext.getSystemService(Context.NFC_SERVICE);
NfcAdapter adapter = manager.getDefaultAdapter();
if (adapter != null && adapter.isEnabled()) {
nfcSupport=true;
//Yes NFC available
}else{
nfcSupport=false;
//Your device doesn't support NFC
}
return nfcSupport;
}
</code>
**Then in your Checkout.java or when you have wallet implemention add this;**
<code>
if(nfcController.NFCsupport()){
//turn on nfc
nfcController.enableNfcPower(true);
//show nfc payment(android pay)
mWALLET_APPEARANCE=Constants.ANDROID_PAY_LIGHT;
createAndAddWalletFragment(mWALLET_APPEARANCE);
Log.d("nfc", "you have nfc support");
}else{
Log.d("nfc", "dont have nfc support");
//show not nfc payment(wallet)
mWALLET_APPEARANCE=Constants.GOOGLE_WALLET_CLASSIC;
createAndAddWalletFragment(mWALLET_APPEARANCE);
}
</code>
**in your createAndAddWalletFragment(int WALLET_APPEARANCE) change the appearance flags;**
<code>
WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
.setBuyButtonText(BuyButtonText.BUY_WITH_GOOGLE)
.setBuyButtonAppearance(WALLET_APPEARANCE)
.setBuyButtonWidth(WalletFragmentStyle.Dimension.MATCH_PARENT);
</code>
**Second, sent the wallet_appareance in the intent;**<br/>
<code>
intent.putExtra("wallet_appearance",mWALLET_APPEARANCE);
</code>
**and in your confirmationActivity update this funcion to listen the event with the logo correctly in the createAndAddWalletFragment();**
<code>
WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
.setMaskedWalletDetailsLogoImageType(mWALLET_APPEARANCE)//from getintent
.setMaskedWalletDetailsTextAppearance(
R.style.BikestoreWalletFragmentDetailsTextAppearance)
.setMaskedWalletDetailsHeaderTextAppearance(
R.style.BikestoreWalletFragmentDetailsHeaderTextAppearance)
.setMaskedWalletDetailsBackgroundColor(
getResources().getColor(R.color.white))
.setMaskedWalletDetailsButtonBackgroundResource(
R.drawable.bikestore_btn_default_holo_light);
</code>
finally in your fullWalletconfirmationbutton.java in the onCreate method dont forget the function useGoogleWallet to create and setup the fragment;
<code>
// Set up an API client;
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.setAccountName(accountName)
.addApi(Wallet.API, new Wallet.WalletOptions.Builder()
.useGoogleWallet()
.setEnvironment(Constants.WALLET_ENVIRONMENT)
.setTheme(WalletConstants.THEME_HOLO_LIGHT)
.build())
.build();
</code>
**and you have android pay and android wallet support.**