编辑器加载中...
/**命令,说明是哪一种查询**/
public static final String KEY_COMMAND="Command";
/**所有数据**/
public static final int VALUE_COMMAND_ALL=0;
/**附近**/
public static final int VALUE_COMMAND_NEAR=1;
/**搜索**/
public static final int VALUE_COMMAND_SEARCH=2;
/**推荐**/
public static final int VALUE_COMMAND_RECOMMEND=3;
/**最新**/
public static final int VALUE_COMMAND_NEWEST=4;
/**热门**/
public static final int VALUE_COMMAND_TOP=5;
/**排行榜**/
public static final int VALUE_COMMAND_RANKING=6;
/****参数--距离--在查找附近时有数据*******/
public static final String KEY_DISTANCE="Distance";
/****参数--坐标--在查找附近时有数据*******/
public static final String KEY_GPS="GPS";
/****参数--过滤--地区--***/
public static final String KEY_FILTER_AREA="FilterArea";
/****参数--过滤--频道**********/
public static final String KEY_FILTER_CHANNEL="FilterChannel";
/****参数--排序--***/
public static final String KEY_SORT="Sort";
/****搜索条件-***/
public static final String KEY_SEARCH_CONDITION="Condition";
/**POST数据结构**/
public static class PostData
{
public int command=0;
public int distance=5000;
public String gps="";
public int filterArea=0;
public int filterChannel=0;
public int sort=-1;
public String condition="";
private static final String POST_URL="http://192.168.11.21/test.php";
private final String DEBUG_TAG = "GoWinHttp";
public String getDataFormHttp()
{
String resultStr="";
HttpClient httpclient = new DefaultHttpClient();
//参数列表
List<NameValuePair> nameValuePairs =new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair(KEY_COMMAND,Integer.toString(command)));
nameValuePairs.add(new BasicNameValuePair(KEY_DISTANCE,Integer.toString(distance)));
nameValuePairs.add(new BasicNameValuePair(KEY_GPS,gps));
nameValuePairs.add(new BasicNameValuePair(KEY_FILTER_AREA,Integer.toString(filterArea)));
nameValuePairs.add(new BasicNameValuePair(KEY_FILTER_CHANNEL,Integer.toString(filterChannel)));
nameValuePairs.add(new BasicNameValuePair(KEY_SORT,Integer.toString(sort)));
nameValuePairs.add(new BasicNameValuePair(KEY_SEARCH_CONDITION,condition));
HttpPost httppost = new HttpPost(POST_URL);
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response;
response=httpclient.execute(httppost);
resultStr=EntityUtils.toString(response.getEntity());
} catch (UnsupportedEncodingException e) {
Log.d(DEBUG_TAG, "UnsupportedEncodingException");
e.printStackTrace();
} catch (ClientProtocolException e) {
Log.d(DEBUG_TAG, "ClientProtocolException");
e.printStackTrace();
} catch (IOException e) {
Log.d(DEBUG_TAG, "IOException");
e.printStackTrace();
}
return resultStr;
}
}