我在Google Play上发布了一个带有应用内结算功能的应用程序,一切正常,直到我将新版本上传到开发者控制台。
如果我上传更新的apk,Google服务器似乎忘记了我的购买。
如果我不更新一切正常,谷歌会返回一个包含我所做的所有购买的捆绑包,这里发生了什么?
//Service to establish a connection with google play
mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
new checkProVersion().execute();
}
};
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
//AsyncTask to check if Pro Version is purchased
class checkProVersion extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
Bundle proBundle = new Bundle();
try {
proBundle = mService.getPurchases(3, getPackageName(), "inapp", null);
} catch (RemoteException e) {
e.printStackTrace();
}
int response = proBundle.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> ownedSkus = proBundle.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> purchaseDataList = proBundle.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
ArrayList<String> signatureList = proBundle.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
if (purchaseDataList.size() > 0) {
for (int i = 0; i < purchaseDataList.size(); i++) {
String purchaseData = purchaseDataList.get(i);
String signature = signatureList.get(i);
String sku = ownedSkus.get(i);
if (verifyPurchase(buildPublicKey(), purchaseData, signature)) {
if(sku.equals("name_of_the_sku")) {
buy_pro_btn.setVisibility(View.GONE);
}
}
}
}
}
return null;
}
}
当我更新应用程序时,purchaseDataList.size()返回0。
谢谢!