我使用的是 httputil 发请求,它给我回的是一段 json 字符串,我用 android5.0.2 的手机调试时,能正确返回 json 字符串,格式如下 :
{"desc":"OK","status":1000,"data":{"wendu":"21","ganmao":"天气转凉,空气湿度较大,较易发生感冒,体质较弱的朋友请注意适当防护。","forecast":[{"fengxiang":"东风","fengli":"3-4 级","high":"高温 24℃","type":"小雨","low":"低温 18℃","date":"6 日星期二"},{"fengxiang":"东南风","fengli":"4-5 级","high":"高温 23℃","type":"小雨","low":"低温 16℃","date":"7 日星期三"},{"fengxiang":"东北风","fengli":"微风级","high":"高温 22℃","type":"小雨","low":"低温 14℃","date":"8 日星期四"},{"fengxiang":"西风","fengli":"微风级","high":"高温 21℃","type":"晴","low":"低温 13℃","date":"9 日星期五"},{"fengxiang":"西北风","fengli":"3-4 级","high":"高温 19℃","type":"多云","low":"低温 12℃","date":"10 日星期六"}],"yesterday":{"fl":"微风","fx":"东风","high":"高温 22℃","type":"小雨","low":"低温 18℃","date":"5 日星期一"},"city":"马鞍山"}}
但是使用另一个 android4.0.3 的手机调试时,却得不到 json 字符串,返回如下:
{"desc":"invilad-citykey","status":1002}
我在 AndroidManifest.xml 文件中设置的是
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="22"
/>
不知道怎么回事,希望遇到类似情形的前辈指导,不胜感激。
1
batman2010 2015-10-06 13:21:38 +08:00
看看 status 1002 对应的错误信息是什么,之后再针对问题想办法。
|
2
HentaiMew 2015-10-06 13:21:47 +08:00
😒明明是服务端返回了不同的 json ,被你说成得不到。
无效的城市 key 错误描述那里 |
3
ufo22940268 2015-10-06 15:02:23 +08:00 via Android
看起来好像是一台手机能读到 gps 另外一台读不到
|
4
iyaozhen 2015-10-06 15:03:19 +08:00 via Android
@ufo22940268 这个比较靠谱,其实估计还是楼长代码的问题。
|
5
bdbai 2015-10-06 15:37:35 +08:00 via iPhone
抓下包,看到底请求了什么。
|
6
onlyxuyang 2015-10-06 20:45:38 +08:00 via Android
加 log 打印一下发出去的请求有没有什么不同啊……
|
8
bdbai 2015-10-19 18:23:11 +08:00 via iPhone
@creatorYC (Windows) 开启 Fiddler 远程访问 手机改一下 Wi-Fi 代理设置即可
|
9
creatorYC OP @onlyxuyang 没有不同啊,也不是乱码,控制台报这个错,找了好久也没解决,唉
01-02 11:32:46.609: E/PhonePolicy(5505): Could not preload class for phone policy: com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback 01-02 12:40:20.569: E/dalvikvm(11859): Could not find class 'android.telephony.CellInfoGsm', referenced from method com.baidu.location.h.c.a 01-02 12:40:20.589: W/dalvikvm(11859): VFY: unable to resolve instanceof 1177 (Landroid/telephony/CellInfoGsm;) in Lcom/baidu/location/h/c; 01-02 12:40:20.529: W/dalvikvm(11859): VFY: unable to find class referenced in signature (Landroid/telephony/CellInfo;) |