我是指这个链接
http://developer.android.com/training/in-app-billing/list-iab-products.html亲爱的所有人,我必须在google play上显示我的应用程序的应用内产品的价格。虽然我试着从google play获取价格,如上面的链接所示…有一个错误,在
" for (String thisResponse : responseList) { "告诉我这些
"Type mismatch: cannot convert from element type Object to String".如何解决此错误?或者,我可以通过哪种方式从google play获得应用内产品价格?
这是我的代码。
ArrayList skuList = new ArrayList();
skuList.add("000001");
skuList.add("gas");
Bundle querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
String mPackagePrice;
try {
Bundle skuDetails = mService.getSkuDetails(3,
getPackageName(), "inapp", querySkus);
int response = skuDetails.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList responseList
= skuDetails.getStringArrayList("DETAILS_LIST");
for (String thisResponse : responseList) {
JSONObject object = new JSONObject(thisResponse);
String sku = object.getString("productId");
String price = object.getString("price");
if (sku.equals("000001")) mPackagePrice = price;
}
}
} catch (RemoteException e) {
e.printStackTrace();
}发布于 2013-03-22 14:05:23
您不能保留ArrayList泛型:
ArrayList<String> skuList = new ArrayList<String>();和
ArrayList<String> responseList = ...发布于 2013-08-21 10:42:37
就像"323go“一样,它会解决你的问题,但是之后,如果你使用的是Eclipse,它会要求你用try/catch围绕这一部分来处理jsonException:
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}你不会有问题的。
https://stackoverflow.com/questions/15563558
复制相似问题