J.D*_*.D. 7 android in-app-purchase in-app-billing google-play-services
我在使用应用内结算流程时遇到了令人沮丧的问题.我在开发控制台中创建了一个新的应用程序,添加了一个名为"P1"的inapp产品,该产品目前处于活动状态; 我上传我的应用程序在Alpha版本,存储,然后提升到测试阶段,添加一个测试帐户,并安装在设备(平板电脑)的APK测试帐户,另一个dev的帐户.
现在,我想查询商店以获取非拥有skus价格等信息.这是我的活动代码:
private void istantiate() {
List<String> tmp = new List<String>();
tmp.add("P1");
final List<String> skus = tmp;
mHelper = new IabHelper(mContext, base64EncodedPublicKey);
// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(true);
//create listener
bListener = new BillingListener(mHelper, mContext);
// Start setup. This is asynchronous and the specified listener will be called once setup completes.
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (!result.isSuccess()) {
// There was a problem.
return;
}
getInventory(skus);
}
});
}
...
private void getInventory(List<String> skuList) {
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// IAB is fully set up. Now, let's get an inventory of stuff we own.
mHelper.queryInventoryAsync(true, skuList, bListener.mQueryFinishedListener);
}
Run Code Online (Sandbox Code Playgroud)
然后当查询完成时,这段代码被调用:
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
if (result.isFailure()) {
// handle error
return;
}
...
}
};
Run Code Online (Sandbox Code Playgroud)
但退回的库存是空的.这是logcat:
12-13 11:21:36.977: D/IabHelper(6034): Billing service connected.
12-13 11:21:36.977: D/IabHelper(6034): Checking for in-app billing 3 support.
12-13 11:21:36.987: D/IabHelper(6034): In-app billing version 3 supported for ***
12-13 11:21:36.987: D/IabHelper(6034): Subscriptions AVAILABLE.
12-13 11:21:36.987: D/IabHelper(6034): Starting async operation: refresh inventory
12-13 11:21:36.987: D/IabHelper(6034): Querying owned items, item type: inapp
12-13 11:21:36.987: D/IabHelper(6034): Package name: ***
12-13 11:21:36.987: D/IabHelper(6034): Calling getPurchases with continuation token: null
12-13 11:21:36.997: D/IabHelper(6034): Owned items response: 0
12-13 11:21:36.997: D/IabHelper(6034): Continuation token: null
12-13 11:21:36.997: D/IabHelper(6034): Querying SKU details.
12-13 11:21:37.097: D/IabHelper(6034): Querying owned items, item type: subs
12-13 11:21:37.097: D/IabHelper(6034): Package name: ***
12-13 11:21:37.097: D/IabHelper(6034): Calling getPurchases with continuation token: null
12-13 11:21:37.097: D/IabHelper(6034): Owned items response: 0
12-13 11:21:37.097: D/IabHelper(6034): Continuation token: null
12-13 11:21:37.097: D/IabHelper(6034): Querying SKU details.
12-13 11:21:37.097: D/IabHelper(6034): Ending async operation: refresh inventory
Run Code Online (Sandbox Code Playgroud)
自我的inapp产品发布以来大约一周,所以这不是时间问题.我试图清除应用数据,然后重启设备.
编辑:使用android.test.purchased作为测试sku,一切正常.
编辑2:SKU是"非托管"
小智 6
我也遇到了这个问题,但是一旦我清除了Google Play应用的应用数据,它就解决了.使用adb:
adb shell pm clear com.android.vending
Run Code Online (Sandbox Code Playgroud)
“拥有的项目响应”报告响应代码,在本例中为 BILLING_RESPONSE_RESULT_OK,值为 0。
查看 IabHelper.queryPurchases 代码和 IabHelper.getSkuDetails,我建议一个好的起点是在 onQueryInventoryFinished 中使用 'inventory.hasDetails("P1")' 或 'inventory.getSkuDetails("P1")' 获取数据。
| 归档时间: |
|
| 查看次数: |
4448 次 |
| 最近记录: |