我可以知道这个http连接有什么问题吗? 运行此操作时,我收到“HTTP问题”。android和数据库之间的连接
public void makeHttpPost(){
try
{
//http post
HttpPost httppost = new HttpPost("http://10.0.2.2/project/login.php");
HttpClient httpclient = new DefaultHttpClient();
httppost.setEntity(new UrlEncodedFormEntity(namevaluepairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}
catch(Exception e)
{
Toast.makeText(getBaseContext(),e.toString() ,Toast.LENGTH_LONG).show();
Toast.makeText(getBaseContext(),"HTTP PROBLEM",Toast.LENGTH_LONG).show();
}
}
u能logcat的?并且是运行在浏览器上的urph url? – KOTIOS
这是错误显示 - > android.os.NetworkOnMainThreadException php url cn运行 – Michelle
好吧,这意味着你运行在OnCreate ur ur url而不是你需要异步任务,这将帮助你.. m后一个答案检查out – KOTIOS