I did a test, that is, I made a purchase in app, but with the code above, it returns that there are no products bought.
I have this code:
mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
try {
Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
int response = ownedItems.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
ArrayList<String> signatureList = ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE");
String continuationToken = ownedItems.getString("INAPP_CONTINUATION_TOKEN");
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);
Utils.showPopUp(PreferencesActivity.this, "Info", "purchaseData: " + purchaseData + "\nsignature: " + signature + "\nsku: " + sku, false);
//TODO REVER
shared.setPurchaseInApp(true);
}
} else {
//TODO REVER
Utils.showPopUp(PreferencesActivity.this, "Info", "Não efectou compras", false);
shared.setPurchaseInApp(false);
initPurchaseInApp();
}
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
};
Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);