Here is the code:
String uriApi = context.getString (R.string.server_api_monitorData);
/ * Create a connection * /
HttpPost request = new HttpPost (uriApi);
/ * Create the parameter list * /
List
params.add (new BasicNameValuePair ("itemId", itemId));
params.add (new BasicNameValuePair ("stattime", stattime));
params.add (new BasicNameValuePair ("statTimeType", statTimeType));
JSONArray array = new JSONArray ();
try {
request.setEntity (new UrlEncodedFormEntity (params, HTTP.UTF_8));
HttpResponse httpResponse = new DefaultHttpClient ()
. Execute (request);
if (httpResponse.getStatusLine (). getStatusCode () == 200) {
/ * Remove the response string * /
String result = EntityUtils.toString (httpResponse.getEntity ());
/ * The server returns json data is converted to JsonOjbect * /
JSONObject jsonObject = new JSONObject (result);
/ * Get the data below JSONArray * /
array = new JSONArray (jsonObject.optString ("data"));
array = getMonitorVSection (array, vsjArray);
/ / Httpclient = new TimeOutSetClient ();
/ / Httpclient.setConnectionTimeOut (15);
} Else {
Log.e ("analyzeJsonService", httpResponse.getStatusLine ()
. ToString ());
}
} Catch (UnsupportedEncodingException e) {
Log.e ("analyzeJsonService:", e.getMessage ());
} Catch (ClientProtocolException e) {
Log.e ("analyzeJsonService:", e.getMessage ());
} Catch (IOException e) {
Log.e ("analyzeJsonService:", e.getMessage ());
} Catch (JSONException e) {
Log.e ("analyzeJsonService:", e.getMessage ());
}
In JSONObject jsonObject = new JSONObject (result); when it resolves the error, and in the simulator can be resolved successfully, but connect the phone to debug on the error, we help ah
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Firmware version of the problem, talk about your environment. Reported nothing wrong, logcat posted under
Reply:
Error message:
Unterminated object at character 145 of {'data': [{'RiverDataID': 51, 'AreaID': '445200 ',' AreaName ':'???????? É ',' SectionCode ':' GD080000000101 ' , 'SectionName': '??????????? è', 'BusinessID': 1, 'StatTime': new Date (1199116800000), 'StatTimeType': 1, 'LevelID': 4, 'LevelName ':' ',' OverItem??? ':' è § ° § ',' MainItem????? ':' è § ° § é???????????????? ? ° § é????? pH?????? é?? é? ° é?????????? °???? ° ¨? °???????? ???????? é??? ° § é??????????? é?????? ±????? °??????? ',' Isok ': false,' CtrlLevel ': 2,' Standard ':'??????????????????????? ° è ¨ ° è ¨ é GB 3838 2002 ' , 'WQAimName': 'Zxh.Meq.Infrastructure.StandardLabel', 'MonAreaIDs': '445200 ',' DutyAreaIDs ': '445200', 'MonAreaNames': '???????? é', 'DutyAreaNames' :}, {'RiverDataID' 'é????????': 114, 'AreaID': '445200 ',' AreaName ':' é ',' SectionCode???????? ':' GD080000000102 ',' SectionName ':'?????? ',' BusinessID ': 1,' StatTime ': new Date (1199116800000),' StatTimeType ': 1,' LevelID ': 6,' LevelName ':'? ???? ¤ ',' OverItem ':'???????????????????????????? é ° § é ° ¤ § è è? ??? ¤ ',' MainItem ':'??????????????????????????? ° ¤ § è è ¤ é ° §??? é????? é?? é? ° é?????????? °?????????? ±????? °????????? ???????????? ・ ° ¨ ° ',' Isok ': false,' CtrlLevel ': 2,' Standard ':'???? ° è ¨ °??????? ? è ¨ é GB 3838 2002 ',' WQAimName??????????? ':' Zxh.Meq.Infrastructure.StandardLabel ',' MonAreaIDs': '440500 ',' DutyAreaIDs': '440500 ', 'MonAreaNames':, 'DutyAreaNames' '± ¤???????':},
'± ¤???????'Virtual machine environment: AVD using the SDK Google APIs (API Level 7), the phone system is android2.2
Reply:
Not solve the problem ah? Tangled ah. . .
Reply:
I have encountered similar problems.
The same requirements.
Reply:
There is no way to solve the problem
No comments:
Post a Comment