0
这可能听起来很奇怪,但它在这里。解析单个字符串
我有一个完美的HTTP发布,现在我得到我的回应,并需要改变的价值。
我的回答是,如果没有有效的回来为NO
,如果有我的响应值将YES.50
我怎样才能把我的最终结果,只是从它那里得到.50?可能用“”或其他替代YES。
最后,我会有一个价格值,这需要从折扣代码中扣除。
我的异步任务:
public class GetPromoTask extends AsyncTask<String, Void, String> {
private Exception exception;
@Override
protected String doInBackground(String... url) {
String result = null;
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url[0]);
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("promo",userPromo));
HttpResponse response;
try {
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = client.execute(post);
promoBuilder = inputStreamToString(response.getEntity().getContent());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(promoBuilder != null){
result = promoBuilder.toString();
}else{
}
return result;
}
protected void onPostExecute(String result) {
Log.d(tag,"Result of POST: " + result);
if(result != null){
}
任何帮助非常感谢!
那么简单但它从来没有什么,我认为这将是哈哈哈 – Keeano