这是我的代码,我有几个问题,因为我对整个服务接收器完全陌生。
它工作正常。我结账,我购买,谷歌说我很快就会收到我的物品。
我的问题是,在应用程序关闭后,或包含处理程序的活动关闭后,我的应用程序仍会收到通知,并且 gem 会更新吗?
任何能更好地帮助我理解这一点的指针或线索都很棒=D
我检查了一下,我的服务仍在后台运行,所以这很好:) 但是更新或接收需要很长时间
有人知道吗?
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
}
};
};