【发布时间】:2014-05-04 10:01:27
【问题描述】:
我的 android 应用程序不断崩溃。 我正在尝试通过 post call 连接到 web 服务。 但是我的应用每次尝试调用网络服务时都会崩溃。
import android.app.Activity;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.IOException;
public class PostActivity extends Activity {
//static String response = null;
public void loadPost() throws IOException {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
String blogFeedUrl = "http://localhost/medapp/public/mobile/post";
HttpGet httpGet = new HttpGet(blogFeedUrl);
httpResponse = httpClient.execute(httpGet); // <-- this is where the application crashes
}
}
【问题讨论】:
-
"crashing" 不是对您的问题的有效描述。阅读基本调试。提示:阅读 logcat,学习如何解释堆栈跟踪。此外,在开始时浏览开发网站上的教程很有用。
标签: android