【发布时间】:2014-09-10 04:37:06
【问题描述】:
我在我的应用中定义了一些应用内产品。我已将 apk 上传到 Google Play,并在 Google Play 上添加了应用内购买产品。
我的ServiceConnection 定义如下:
ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
connect();
}
};
onServiceConnected 函数被调用,bindService 返回 true。
接下来是connect 函数。
public void connect() {
new Thread(new Runnable() {
public void run() {
try {
// Purchase type is "inapp", as required by API v3
Bundle skuDetails = mService.getSkuDetails(3, PACKET, "inapp", querySkus);
}
int response = skuDetails.getInt("RESPONSE_CODE");
Log.e("IAP connect", response + "");
if (response == 0) {
ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
Log.e("size list", responseList.size()+"");
...
}
}
} catch (RemoteException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
}
}).start();
}
此处的 PACKET 设置为 getPackageName()。
响应代码为 0,但日志显示列表的大小为 0。我不知道为什么列表为空,因为我在 Google Play 中总共输入了 5 个项目,并且每个项目都处于活动状态。我已经等了 2 天了,用三台设备进行了测试,但仍然没有通过。
我几乎尝试了我能想到的一切,欢迎提出任何建议。
【问题讨论】:
标签: android in-app-billing skus