これが私のコードです
public class RequestTask extends AsyncTask<String, String, String>{
@Override
protected String doInBackground(String... uri) {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
String responseString = null;
try {
HttpGet get = new HttpGet(uri[0]);
Log.v("test","start RESPONSE");
response = httpclient.execute(get);
StatusLine statusLine = response.getStatusLine();
if(statusLine.getStatusCode() == HttpStatus.SC_OK){
Log.v("test","status complete");
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
responseString = out.toString();
} else{
response.getEntity().getContent().close();
throw new IOException(statusLine.getReasonPhrase());
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return responseString;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
}
}
uri[0] = " http://www.google.com " の場合、エラーは発生せず、Log.v("test","status complete") が表示されます。でもいつ
uri[0] = "http://best12t.gosoft.com/web_service/counter/CSTrack2.aspx?cli=focusgroup&cam=androidtest&1=W_S_UID&2=W_S_SC&3=W_S&5=W_S_DATE&7=www.gocorp.com&8=www.gocorp.com%2Ftc%2F&9=&10=W_S_IP&11=www.gocorp.com&12=www.gocorp.com%2F&13=&14=website&15=W_S&16=W_S&17=W_S&19=windows&20=Win%207(x64)&21=1&22=9.0&23=1366x768&24=1&25=1&6=CRM%20%26%20%u6578%u4F4D%u884C%u92B7%u7684%u9818%u5C0E%u8005%20-%20MIGO%20CORP%20%u529F%u5178%u96C6%u5718%20&1375088741345"
エラーが発生し、仮想デバイスが停止して「残念ながらアプリが停止しました」と表示されます。さらに、Log.v("test","start RESPONSE") が LogCat に表示されません。
Web ブラウザーでこの URL を入力する別のアプリを試してみましたが、動作し、Web からこのメッセージを取得できます。
httpgetを使用する際の制限はありますか?
手伝ってくれてありがとう!