|
|
|
@ -1,8 +1,11 @@
|
|
|
|
|
package com.example.PersonalCenter;
|
|
|
|
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import net.sf.json.JSONArray;
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
@ -26,7 +29,7 @@ public class SearchServiceGet {
|
|
|
|
|
|
|
|
|
|
String address="/rest/cmkg/question/hello";
|
|
|
|
|
|
|
|
|
|
String Url = "http://114.116.199.154:5000"+address;
|
|
|
|
|
String Url = "http://114.116.199.154:5000/cmkg"+address;
|
|
|
|
|
String path = Url + "?name="+name;
|
|
|
|
|
URL url = null;
|
|
|
|
|
try {
|
|
|
|
@ -50,19 +53,53 @@ public class SearchServiceGet {
|
|
|
|
|
System.out.println(response.toString());
|
|
|
|
|
|
|
|
|
|
//开始解析返回的数据
|
|
|
|
|
JSONObject jo=JSONObject.fromObject(response.toString());
|
|
|
|
|
code=jo.getInt("code");
|
|
|
|
|
System.out.println("code==@@@@@@@@@@20"+code);
|
|
|
|
|
// JSONObject jo=JSONObject.fromObject(response.toString());
|
|
|
|
|
org.json.JSONObject jo = null;
|
|
|
|
|
try {
|
|
|
|
|
jo = new org.json.JSONObject(response.toString());
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
code=jo.getInt("code");
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
System.out.println("code="+code);
|
|
|
|
|
if(code!=0){ //查询成功,在开始解析数据
|
|
|
|
|
System.out.println("code==@@@@@@@@@@20"+code);
|
|
|
|
|
name_back=jo.getString("message");//查询的主语
|
|
|
|
|
try {
|
|
|
|
|
name_back=jo.getString("message");//查询的主语
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
//把data看作一个JSONObject,无论里面由多少元素,都转换为JSONArray,存在数组里
|
|
|
|
|
JSONObject jo_data=jo.getJSONObject("data");
|
|
|
|
|
JSONArray data_arr=null;
|
|
|
|
|
jo_data.toJSONArray(data_arr);
|
|
|
|
|
JSONObject jo_data= null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
jo_data = jo.getJSONObject("data");
|
|
|
|
|
if(jo_data==null) System.out.println(("jo_data==null"));
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
JSONArray data_arr=new JSONArray();
|
|
|
|
|
ArrayList<String> datas=new ArrayList<String>();
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
// jo_data.toJSONArray(data_arr);
|
|
|
|
|
datas.add(jo_data.toString());
|
|
|
|
|
data_arr=jo.getJSONArray("data");
|
|
|
|
|
System.out.println("data_arr======"+data_arr.length());
|
|
|
|
|
} catch (JSONException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
//遍历data_arr,把里面的数据放入ArrayList<String> content里
|
|
|
|
|
for(int i=0;i<data_arr.size();i++){
|
|
|
|
|
content.add(data_arr.get(i).toString());
|
|
|
|
|
for(int i=0;i<datas.size();i++){
|
|
|
|
|
try {
|
|
|
|
|
content.add(datas.get(i));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SearchSuccess=true;//查找成功标志
|
|
|
|
|
}
|
|
|
|
@ -91,11 +128,10 @@ public class SearchServiceGet {
|
|
|
|
|
public static void exxcuteTest(String name){
|
|
|
|
|
code=100;
|
|
|
|
|
name_back="糖尿病";
|
|
|
|
|
content.add("jjfkdjfkjklfjdklsjfklasjflksjflsjfdlsjfdklsjfklsjfklsjfkldjsafl;das"
|
|
|
|
|
+"FJDKSLDJFKLDSKLFJDSKLAJFKLDSAJFKLDASJFKLDSAJFKLDSAJFKLDASJFKLDASJFKLDASJFKLDASJFL"
|
|
|
|
|
+"FNDFJDJFKLDSJFKLDSJFIOWUIORUEJGKLDKLGDKSLFJKDLSAJFKLD;SA");
|
|
|
|
|
content.add("dddddddd反馈i惹我给i偶i哦好v考虑的设计规范房价的快速了解法拉盛覅柔儿一个可能"
|
|
|
|
|
+"fdighreioghi飞机迪斯科飞机俄欧分工i热i购房贷款了JFK逻辑非我");
|
|
|
|
|
content.add("莲子粥");
|
|
|
|
|
content.add("推拿法");
|
|
|
|
|
content.add("大蒜蒸西瓜");
|
|
|
|
|
content.add("红枣糕");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|