我可以知道這個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