我正在尝试将应用内欺诈包含在我的应用中。我应该提一下,我已经在我的Google Play开发者控制台中激活了产品ID,但我还没有发布该应用。我正在尝试在上传我的最终apk之前在我的设备中测试应用内购买。当我点击启动launchPurchaseFlow方法的按钮时出现错误。 (当我访问Google Play商店并尝试下载任何应用时,它不会要求我进行任何身份验证,它只是下载应用):
这是我的onOptionsItemSelected方法中的代码,我调用的是launchPurchasedFlow方法。
public boolean onOptionsItemSelected(MenuItem item) {
if(id == R.id.action_remove_adds){
mHelper.launchPurchaseFlow(this,SKU_REMOVE_ADDS,1,mPurchasedFinishedListener,"");
}
return super.onOptionsItemSelected(item);
}
这是我的mPurchasedFinishedListener代码:
private IabHelper.OnIabPurchaseFinishedListener mPurchasedFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
return;
}
else if (purchase.getSku().equals(SKU_REMOVE_ADDS)) {
// consume the gas and update the UI
}
}
};
这是我的onActicity结果代码:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
// not handled, so handle it ourselves (here's where you'd
// perform any handling of activity results not related to in-app
// billing...
super.onActivityResult(requestCode, resultCode, data);
}
else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
}
}
答案 0 :(得分:1)
应用内购买仅适用于已发布的应用,可上传为alpha或beta,您可以对其进行测试。
这是因为Google需要知道用于启用IAB的apk版本代码,如果版本代码不在Google Play中,Google将不会激活购买,因为apk未注册。