私は次のようにHTTP接続を使用しています。
HttpConnection _httpConnection = null;
try {
_httpConnection = (HttpConnection)Connector.open(_url);
} catch(Exception e) { }
byte [] postDataBytes = _postData.getBytes();
_httpConnection.setRequestMethod(HttpConnection.POST);
_httpConnection.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0");
_httpConnection.setRequestProperty("Content-Language", "en-US");
_httpConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
_httpConnection.setRequestProperty("Connection", "close");
_httpConnection.setRequestProperty("Content-Length", Integer.toString(_postData.getBytes().length));
os = _httpConnection.openOutputStream();
os.write(postDataBytes);
os.flush();
このHTTP接続を正常に開くには、パラメーターが必要です。たとえば、WIFIネットワークでは、「; deviceside = true; interface=wifi」をURLに追加する必要があります。
問題はEDGE接続にあります。国ごとに異なるパラメータを追加する必要があります。たとえば、レバノンでは「; deviceside = false」が必要ですが、KSAでは、このパラメーターを追加すると接続が開きません。米国では、さまざまな種類のパラメータが必要です。問題は、同じパラメータですべての国にHTTP接続を確立する方法です。アプリケーションがどこにダウンロードされても、アプリケーションが正常にインターネットに接続できるようにします。