Android应用连接数据库

时间:2015-05-08 07:22:52

标签: php android wamp

我希望通过将通过应用程序输入的数据与数据库进行比较来显示成功或失败。比较代码在php中完成,我必须显示由php.But返回的字符串执行以下代码时,一些html文件是显示为toast.please帮助我

InputStream is = null;
            try {
                is = response.getEntity().getContent();
            } catch (IllegalStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            final String responseMsg2 = convertStreamToString(is);
             runOnUiThread(new Runnable(){

                  @Override
                  public void run(){
                    //update ui here

                Toast.makeText(getApplicationContext(),responseMsg2,Toast.LENGTH_LONG).show();
                  }
               });

1 个答案:

答案 0 :(得分:0)

当您使用response.getEntity().getContent();时,您将整个响应作为字符串(包括标签等)获得。所以你需要这样做:

String responseMsg2 = convertStreamToString(is);
final String responseAsText = android.text.Html.fromHtml(responseMsg2).toString();

然后在Toast中使用没有html标签的文本:

Toast.makeText(getApplicationContext(),responseAsText,Toast.LENGTH_LONG).show();
相关问题