我在應用中定義了一些應用產品。我已將APK上傳到Google Play,並在Google play上添加了inapp購買產品。Android inapp計費responseList爲空
我有我的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();
}
此處的數據包設置爲getPackageName()
。 響應代碼爲0,但Log記錄了列表大小爲0.我不知道爲什麼列表是空的,因爲我已向Google Play輸入了總共5個項目,並且每個項目都處於活動狀態。我已經等了2天,並用三種設備進行測試,但仍沒有任何項目能夠通過。
我幾乎想盡辦法想,所以有任何建議都是值得歡迎的。
這很奇怪。在另一個運行幾乎完全相同的代碼的項目中,最顯着的還是運行版本3,它使用非託管產品很好。 – Gooey
它的確如此:「如果您使用應用內結算v3而非應用內結算v2,則非託管產品的行爲會有所不同。如果您使用應用內結算v3,則非託管產品會被視爲託管產品,並且需要明確使用。瞭解更多信息「但是,我還沒有購買任何東西,而且我運行了一個消耗購買量的(冗餘)循環。 – Gooey
那麼,也許你是對的。那麼我唯一的想法是你的應用程序沒有發佈。您是否已將其發佈到(Beta/Alpha)或者是否在草稿中? – kupsef