phpjavaeclipseandroid
我想在数据库中放入一个entry。用的下面的代码:
String url = String.format("http://xxxxxxx/xxx/index.php?home=yes&pid=%s", pid); // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); try { ResponseHandler<string> responseHandler = new BasicResponseHandler(); String response = httpclient.execute(httppost, responseHandler); Log.e("abc", response); return response; } catch (ClientProtocolException es) { Log.e("x" , es.getMessage()); return ""; } catch (IOException e) { Log.e("aasx" , e.getMessage()); return ""; }</string>
这段代码能正常运行,现在当有网络连接的时候,代码就会困在httpclient.execute(httppost, responseHandler); 大约俩分钟。
有什么方法可以实现检查几秒钟后,如果没有反应的就会就catch the exceptions?
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!










