Android 从google play获取应用内产品价格
我指的是这个链接Android 从google play获取应用内产品价格,android,android-billing,Android,Android Billing,我指的是这个链接 http://developer.android.com/training/in-app-billing/list-iab-products.html 亲爱的各位, 我必须显示我的应用程序的应用程序内产品的价格从谷歌播放。 虽然我试图从谷歌游戏中获取价格,如上面的链接所示。。。 上有一个错误 " for (String thisResponse : responseList) { " 告诉你 "Type mismatch: cannot convert from eleme
http://developer.android.com/training/in-app-billing/list-iab-products.html
亲爱的各位,
我必须显示我的应用程序的应用程序内产品的价格从谷歌播放。
虽然我试图从谷歌游戏中获取价格,如上面的链接所示。。。
上有一个错误
" 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();
}
您不能将
ArrayList
generic:
ArrayList<String> skuList = new ArrayList<String>();
ArrayList skuList=new ArrayList();
及
ArrayList responseList=。。。
与“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();
}
它们会很好的。使用泛型类型创建ArrayList,如“ArrayList responseList”
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}