在Android中获取PHP Echo
我在从网站接收PHP回显消息时遇到一些问题。 我有以下代码:在Android中获取PHP Echo,php,android,androidhttpclient,Php,Android,Androidhttpclient,我在从网站接收PHP回显消息时遇到一些问题。 我有以下代码: HttpClient httpclient=new DefaultHttpClient(); HttpPost httppost=new HttpPost("http://www.itbstudios.tk/test.php"); HttpResponse response = httpclient.execute(httppost); String str = EntityUtils.toString(res
HttpClient httpclient=new DefaultHttpClient();
HttpPost httppost=new HttpPost("http://www.itbstudios.tk/test.php");
HttpResponse response = httpclient.execute(httppost);
String str = EntityUtils.toString(response.getEntity());
我在stackoverflow上找到了这段代码和更多内容,但它不起作用。应用程序正在运行httpclient.execute()代码>
在android清单中设置了Internet权限
Php代码只是一个
我正在为API 15进行构建,并在HTC设备上进行测试
你们能帮帮我吗?
我甚至创建了另一个项目,并将代码粘贴到create上,我也遇到了同样的问题
谢谢 HttpClient在API中有一些高于10的错误。改用HttpUrlConnection
获取方法示例:
URL url = new URL("http://www.itbstudios.tk/test.php");
HttpUrlConnection mUrlConnection = (HttpURLConnection) url.openConnection();
mUrlConnection.setDoInput(true);
InputStream is = new BufferedInputStream(mUrlConnection.getInputStream());
String s = readStream(is);
HttpClient在API中有一些高于10的错误。改用HttpUrlConnection
获取方法示例:
URL url = new URL("http://www.itbstudios.tk/test.php");
HttpUrlConnection mUrlConnection = (HttpURLConnection) url.openConnection();
mUrlConnection.setDoInput(true);
InputStream is = new BufferedInputStream(mUrlConnection.getInputStream());
String s = readStream(is);
HttpClient在API中有一些高于10的错误。改用HttpUrlConnection
获取方法示例:
URL url = new URL("http://www.itbstudios.tk/test.php");
HttpUrlConnection mUrlConnection = (HttpURLConnection) url.openConnection();
mUrlConnection.setDoInput(true);
InputStream is = new BufferedInputStream(mUrlConnection.getInputStream());
String s = readStream(is);
HttpClient在API中有一些高于10的错误。改用HttpUrlConnection
获取方法示例:
URL url = new URL("http://www.itbstudios.tk/test.php");
HttpUrlConnection mUrlConnection = (HttpURLConnection) url.openConnection();
mUrlConnection.setDoInput(true);
InputStream is = new BufferedInputStream(mUrlConnection.getInputStream());
String s = readStream(is);
你能发布你在LogCat中看到的错误吗?当我尝试转到时,它不会加载并超时。如果服务器首先工作,这会有所帮助。可能是NetworkOnMainThreadException…它是另一个错误NetworkOnMainThreadException您可以发布在LogCat中看到的错误吗?当我尝试转到时,它不会加载并超时。如果服务器首先工作,这会有所帮助。可能是NetworkOnMainThreadException…它是另一个错误NetworkOnMainThreadException您可以发布在LogCat中看到的错误吗?当我尝试转到时,它不会加载并超时。如果服务器首先工作,这会有所帮助。可能是NetworkOnMainThreadException…它是另一个错误NetworkOnMainThreadException您可以发布在LogCat中看到的错误吗?当我尝试转到时,它不会加载并超时。如果服务器首先工作,则会有所帮助。可能是NetworkOnMainThreadException…如果是NetworkOnMainThreadException,则另一个错误是NetworkOnMainThreadException,而不是使用readstrem(is),请使用s=IOUtils.toString(is)@引用未包含的非标准类与引用未包含的自定义方法无异。请使用s=IOUtils.toString(is)代替readstrem(is)@引用未包含的非标准类与引用未包含的自定义方法无异。请使用s=IOUtils.toString(is)代替readstrem(is)@引用未包含的非标准类与引用未包含的自定义方法无异。请使用s=IOUtils.toString(is)代替readstrem(is)@引用未包含的非标准类与引用未包含的自定义方法没有什么不同。