Hi
I was integrating In app billing into my application. I used the code below which I got from google's development site:
http://stackoverflow.com/questions/24209065/in-app-billing-crash
I used the android.test.purchased to test the in app billing. When I click on the download button it buys the test opbject without flaws. But as soon as I try to buy it again the app crashes, the item people can buy in my app must be buyable multiple times. Can someone tell me how to fix this?
Thank you in advance!
I was integrating In app billing into my application. I used the code below which I got from google's development site:
buttonDownload = (Button) findViewById(R.id.download);
buttonDownload.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ArrayList skuList = new ArrayList();
skuList.add(inappid);
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
Bundle skuDetails;
try {
skuDetails = mservice.getSkuDetails(3, getPackageName(),
"inapp", querySkus);
int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> responseList = skuDetails
.getStringArrayList("DETAILS_LIST");
for (String thisResponse : responseList) {
JSONObject object = new JSONObject(thisResponse);
String sku = object.getString("productId");
String price = object.getString("price");
if (sku.equals(inappid)) {
System.out.println("price " + price);
Bundle buyIntentBundle = mservice
.getBuyIntent(3, getPackageName(), sku,
"inapp",
"bGoa+V7g/WqDXvKRqq+JTFn4uQRbPiQJEipf9RzJ");
PendingIntent pendingIntent = buyIntentBundle
.getParcelable("BUY_INTENT");
startIntentSenderForResult(
pendingIntent.getIntentSender(), 1001,
new Intent(), Integer.valueOf(0),
Integer.valueOf(0), Integer.valueOf(0));
}
}
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SendIntentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
buttonDownload.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ArrayList skuList = new ArrayList();
skuList.add(inappid);
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
Bundle skuDetails;
try {
skuDetails = mservice.getSkuDetails(3, getPackageName(),
"inapp", querySkus);
int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> responseList = skuDetails
.getStringArrayList("DETAILS_LIST");
for (String thisResponse : responseList) {
JSONObject object = new JSONObject(thisResponse);
String sku = object.getString("productId");
String price = object.getString("price");
if (sku.equals(inappid)) {
System.out.println("price " + price);
Bundle buyIntentBundle = mservice
.getBuyIntent(3, getPackageName(), sku,
"inapp",
"bGoa+V7g/WqDXvKRqq+JTFn4uQRbPiQJEipf9RzJ");
PendingIntent pendingIntent = buyIntentBundle
.getParcelable("BUY_INTENT");
startIntentSenderForResult(
pendingIntent.getIntentSender(), 1001,
new Intent(), Integer.valueOf(0),
Integer.valueOf(0), Integer.valueOf(0));
}
}
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SendIntentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
http://stackoverflow.com/questions/24209065/in-app-billing-crash
I used the android.test.purchased to test the in app billing. When I click on the download button it buys the test opbject without flaws. But as soon as I try to buy it again the app crashes, the item people can buy in my app must be buyable multiple times. Can someone tell me how to fix this?
Thank you in advance!