Не отправляется GET запрос на android 4.0.3
Добавлено: 28 авг 2013, 15:26
Не могу понять из-за чего не отправляется GET запрос. На 2.3.3 норм отправляется а на 4.0.3 нет
В чём проблема?
Прошу помочь))
Код: Выделить всё
package com.androidexample.httpgetexample;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class HttpGetAndroidExample extends Activity implements OnClickListener{
String content;
Button save;
final String LOG_TAG = "myLogs";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_http_get_android_example);
save = (Button) findViewById(R.id.save);
save.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if(v == save)
{
GetReq();
}
}
public void GetReq() {
try {
HttpClient Client = new DefaultHttpClient();
String URL = "http://forum.startandroid.ru/posting.php?mode=post&f=41";
try {
HttpGet httpget = new HttpGet(URL);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String SetServerString = "";
SetServerString = Client.execute(httpget, responseHandler);
content = SetServerString;
Log.d(LOG_TAG, "Response: " + content);
} catch (Exception ex) {
content = "Fail!";
Log.d(LOG_TAG, "Response: " + content);
}
} catch (Exception ex) {
content = "Fail!!!";
Log.d(LOG_TAG, "Response: " + content);
}
}
}Прошу помочь))