Here is my code, I have a few questions as I am completely new to this whole service receiver thing.
It works fine. I get to checkout,I purchase, google says I will receive my item soon.
My question is that after the application gets closed, or after the activity that contains the handler is closed, will my app still receive the notification, and the gems be updated?
Any pointers or clues to better help me understand this would be awesome =D
I checked and my service is still running in the background, so this is good 🙂
But it is taking forever to update, or to receive
does anyone know?
Button bPurchase = (Button) findViewById(R.id.bPurchase);
bPurchase.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox confirm = (CheckBox) findViewById(R.id.bConfirm);
if (!confirm.isChecked()) {
Toast msg = Toast.makeText(PurchaseActivity.this, "Please Check Confirmation box", Toast.LENGTH_SHORT);
msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2);
msg.show();
return;
}
if(BillingHelper.isBillingSupported()){
BillingHelper.requestPurchase(mContext, "android.test.purchased");
// android.test.purchased or android.test.canceled or android.test.refunded
} else {
Log.i("","Can't purchase on this device");
}
}
});
}
public Handler mTransactionHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
Log.i("", "Transaction complete");
Log.i("", "Transaction status: "+BillingHelper.latestPurchase.purchaseState);
Log.i("", "Item attempted purchase is: "+BillingHelper.latestPurchase.productId);
if(BillingHelper.latestPurchase.isPurchased()){
long g = GemUpgrades.getGems();
g = g + 1000;
GemUpgrades.setGems(g);
Toast msg1 = Toast.makeText(PurchaseActivity.this, "Received", Toast.LENGTH_SHORT);
msg1.setGravity(Gravity.CENTER, msg1.getXOffset() / 2, msg1.getYOffset() / 2);
msg1.show();
} else {
// Failure
}
};
};
SO I discovered that i was not receiving my calls because I forgot to set the Handler as the Handler. Also It seemed it updated outside the activity, and pretty quick too. But would it still update if the app has been closed before it gets its updat