【发布时间】:2013-06-15 22:32:49
【问题描述】:
我尝试将我的应用放入 In app billing v3。
我关注了:http://developer.android.com/google/play/billing/billing_integrate.html
我在 3 天内将我的应用上传到开发者控制台并设置在应用产品中。
我输入了我的 Base64 编码的 RSA 公钥和我的应用内产品 ID。
当我开始购买时,我收到错误消息。当我检查我的 RESPONSE_CODE 时,它是 5 和谷歌
应用内结算参考 (http://developer.android.com/google/play/billing/billing_reference.html#billing-codes)
我的应用设置似乎有问题。
当我尝试像 android.test.purchased 这样的谷歌测试 ID 时,我得到了很好的结果。
这是我的代码,也许我在这里做错了:
some_id is my test in app product id.
protected void onCreate(Bundle savedInstanceState) {
..
..
..
Helper = new IabHelper(this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
Toast.makeText(getApplicationContext(), "connection bad",Toast.LENGTH_SHORT).show();
}
Toast.makeText(getApplicationContext(), "connection good",Toast.LENGTH_SHORT).show();
}
});
mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name,
IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
};
bindService(new
Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);
...
...
..
我的购买代码:
IabHelper.QueryInventoryFinishedListener
mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory)
{
if (result.isFailure()) {
// handle error
return;
}
String applePrice =
inventory.getSkuDetails("some_id").getPrice();
// update the UI
}
};
ArrayList<String> skuList = new ArrayList<String>();
skuList.add("some_id");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
Bundle skuDetails = new Bundle();
try {
skuDetails = mService.getSkuDetails(3, getPackageName(), "inapp", querySkus);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String sku = "some_id";
Bundle buyIntentBundle = new Bundle();
try {
buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "j");
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
try {
startIntentSenderForResult(pendingIntent.getIntentSender(),1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
} catch (SendIntentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
【问题讨论】:
-
您是否尝试通过您的开发者帐户测试应用计费?您是否将您的帐户声明为测试员帐户?您是否在控制台中启用了购买功能?
-
我正在使用具有开发者帐户的真实设备。我没有将其标记为测试人员,开发人员是否应该将自己声明为测试人员?我不确定在控制台中启用购买的功能,如果这就是您的意思,请将我的产品状态设置为活动。