1

Web サイトで単純な HTTP POST リクエストを作成するのに問題があります。POST パラメータが送信されていないようです。
シナリオ:
HTTP 応答コード 200 - 間違ったユーザー/パス - Android 4.0+ で発生
HTTP 応答コード 302 - ユーザー/パス OK - 他の SDK バージョンで発生

問題なく動作する Web フォーム:

<form id="form_mn_login" enctype="application/x-www-form-urlencoded" action="http://dummyhost/r.php" class="estil" accept-charset="utf-8" method="post">
<input type="text" name="m_email" id="m_email" />
<input type="password" name="m_senha" id="m_senha" />

コード (doInBackground AsyncTask のメソッド内):

urlParameters = "m_email="
                    + URLEncoder.encode(username, "UTF-8") + "&m_senha="
                    + URLEncoder.encode(password, "UTF-8");

            URL url;
            HttpURLConnection connection = null;

            // Create connection
            url = new URL("http://dummyhost/r.php");
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type",
                    "application/x-www-form-urlencoded");
            connection.setRequestProperty("Content-Language", "en-US");

            connection.setUseCaches(false);
            connection.setDoInput(true);
            connection.setDoOutput(true);

            // Send request
            DataOutputStream wr = new DataOutputStream(
                    connection.getOutputStream());
            wr.writeBytes(urlParameters);
            wr.flush();
            wr.close();
            publishProgress(30);


            Log.w("responsecode", Integer.toString(connection.getResponseCode()));

この問題は、Android 4.0 以降の AVD デバイスでエミュレートした場合にのみ発生します。(2.2、2.3.3、3.0 で試してみましたが、問題なく動作します) 何が欠けていますか?

これがサーバーの問題である可能性があることは承知していますが、これには回避策が必要であると本当に信じています. 私はそれを行うために何千もの異なる方法を試しましたが、どれもうまくいかないようです.

どうもありがとう、RC

4

0 に答える 0