Php onPostExecute方法的If语句未执行

Php onPostExecute方法的If语句未执行,php,android,mysql,Php,Android,Mysql,如果来自服务器的响应等于“连接成功..登录成功”,我想转到另一个活动。在我的php代码中,我回显“connection success..Login success”以获取doInbackground()收到的正确详细信息……但每次只执行else部分。 整个代码都是AsyncTask的一部分…就这样 @Override protected void onPostExecute(String s) { String s1=s.toString(); String ls= "Con

如果来自服务器的响应等于“连接成功..登录成功”,我想转到另一个活动。在我的php代码中,我回显“connection success..Login success”以获取doInbackground()收到的正确详细信息……但每次只执行else部分。 整个代码都是AsyncTask的一部分…就这样

@Override
protected void onPostExecute(String s) {

    String s1=s.toString();
    String ls= "Connection success...Login Success";
    String rs= "Connection success...Registered Successfully";
    loading.dismiss();
        if(s1.equals(ls))
        {

            Intent intent = new Intent(ctx,MainActivity.class);
          //  intent.putExtra("USER_NAME",login_name);
            ctx.startActivity(intent);

        }


   /*     else{
            Toast.makeText(ctx,result,Toast.LENGTH_LONG).show();
        }
    }
    else if(method.equals("register")) {
   */
        else if(s1.equals(rs)){
            Intent intent = new Intent(ctx,Login.class);
            ctx.startActivity(intent);
        }
        else{
            Toast.makeText(ctx,s1,Toast.LENGTH_LONG).show();

        }
   // }
}
字符串doInBacground(字符串…参数)中的代码如下


}

返回doInBackground时,您能发布其中包含的响应吗?从Php中,我将以“连接成功..登录成功”的形式发送响应。此消息从服务器发送,该服务器由缓冲区读取,并返回到onPostExecute方法,以便comaparison@Automatik从Php发送的响应为“连接成功..登录成功”。此消息从服务器发送,该服务器由缓冲区读取,并返回到onPostExecute方法以进行比较
public String doInBackground(String... params) {


        String reg_url="http://10.0.2.2/webapp/Register.php";
        String login_url="http://10.0.2.2/webapp/login.php";
       String method= params[0];
if (method.equals("login")) {
                String login_name = params[1];
                String login_pass = params[2];
                try {
                    URL url = new URL(login_url);
                    HttpURLConnection httpURLConnection=(HttpURLConnection)url.openConnection();
                    httpURLConnection.setRequestMethod("POST");
                    httpURLConnection.setDoOutput(true);
                    httpURLConnection.setDoInput(true);
                    OutputStream os = httpURLConnection.getOutputStream();
                    BufferedWriter bufferedWriter= new BufferedWriter(new OutputStreamWriter(os,"UTF-8"));
                    String data = URLEncoder.encode("login_name","UTF-8")+"="+URLEncoder.encode(login_name,"UTF-8")+"&"+
                            URLEncoder.encode("login_pass","UTF-8")+"="+URLEncoder.encode(login_pass,"UTF-8");

                    bufferedWriter.write(data);
                    bufferedWriter.flush();
                    bufferedWriter.close();
                    os.close();

                    InputStream inputStream=httpURLConnection.getInputStream();
                    BufferedReader bufferedReader= new BufferedReader(new InputStreamReader(inputStream,"iso-8859-15"));
                    String response="";
                    String line="";
                    while ((line=bufferedReader.readLine())!=null)
                    {
                        response+=line;
                    }
                    bufferedReader.close();
                    inputStream.close();
                    httpURLConnection.disconnect();
                    return response;

                }
            return null;