Php 安卓&x2B;mysql+;登录

Php 安卓&x2B;mysql+;登录,php,android,mysql,error-handling,Php,Android,Mysql,Error Handling,我正在创建一个登录过程测试,使用php和mysql连接到android上的数据库,但是我在日志中发现了cat错误,在模拟器上有一个force close,有人能帮我吗 AndroidLogin.java login.php 您的代码非常完美,只需执行以下操作: 如果您正在使用上述3.0 android操作系统,请将其放入onCreate StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll

我正在创建一个登录过程测试,使用php和mysql连接到android上的数据库,但是我在日志中发现了cat错误,在模拟器上有一个force close,有人能帮我吗

AndroidLogin.java login.php
您的代码非常完美,只需执行以下操作:

如果您正在使用上述
3.0 android操作系统
,请将其放入
onCreate

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
或者您可以使用
AsyncTask
检查此项

相反

String str = inputStreamToString(response.getEntity().getContent()).toString();
使用

打印日志首先检查你得到了什么

Log.e("Responce-->",""+str);

查看日志中的时间(甚至是编辑之前的旧时间),似乎
httpclient.execute
调用从未返回/超时

模拟器是否可以访问login.php,并且login.php是否正常工作? 使用模拟器上的浏览器进行检查


除此之外,您不应该在onClick处理程序中执行任何耗时的操作。

我仍然会在log cat中遇到错误,请参见上面的log cat(我是android新手,因此需要帮助)log cat没有进入log.e(“response-->”,或“+str”);所以我认为错误在这之前OK我使用了严格模式,我在log_cat中得到了这个,在模拟器a上得到了一个力关闭(见上面的log cat)您正在获取keyDispatchingTimedOut,因此将您的方法放在异步任务中检查此链接:好的,先生,我使用了后台线程,但仍然无法获得正确的响应,我认为错误在execute hhtpresponse(编辑上面的日志和安卓login.java)中,从DDMS-->file Explorer导出此文件/data/anr/traces.txt
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
String str = inputStreamToString(response.getEntity().getContent()).toString();
String str = EntityUtils.toString(response.getEntity(), HTTP.UTF_8);
Log.e("Responce-->",""+str);