私は、Http Connectionを使用してサーバーにデータを投稿するアプリケーションを作成しています。エミュレータでチェックすると、私のアプリケーションは正常に動作しています。私のWebサービスは応答を生成するのに時間がかかり、エミュレータも適切な方法で応答しています。何とか私はデバイスにアプリケーションをインストールすると、私のアプリは、サーバー上でデータを2回転記しています。私はそれをチェックした...誰もこれから逃げる方法の任意の解決策を持っていますか?HTTP接続データを2回投稿する
ここでは、送信リクエストのコードを添付しています。私はそれがHTTPのタイムアウトに達すると、モバイルアプリは別の要求を送信していると思うが、私は何が問題なのか分からない。私を助けてください。
String param=
"function=OpenRecharge&LoginId="+SharedVariable.getUserInfo().getLoginID()
+"&BatchId="+SharedVariable.getSelectedProduct().getBatchID()
+"&SystemServiceID="+SharedVariable.getSelectedProduct().getSystemServiceID()
+"&ReferalNumber="+strMobileNo
+"&Amount="+strAmount
+"&FromANI="+fromMoNo
+"&Email="
+"&Checksum="+Checksum;
System.out.println("Final Parameter:\n"+param);
connection = (HttpConnection) Connector.open(url);
//Connector.open(param, strAmount, quit)
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
connection.setRequestProperty("Accept_Language","en-US");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
OutputStream out = connection.openOutputStream();
out.write(param.getBytes());
out.flush();
//System.out.println("Status Line Code: " + connection.getResponseCode());
//System.out.println("Status Line Message: " + connection.getResponseMessage());
is=connection.openDataInputStream();
int chr;
StringBuffer sb=new StringBuffer();
while ((chr = is.read()) != -1)
sb.append((char) chr);
System.out.println("Response===>"+sb.toString());
私はonCreateとonResumeの両方に同じコードがあることが強く思われます。 – kosa
完全なコードの引用符がない場合、thinksteepのコメントに可能な限りの理由があると思います – Kerry
@thinksteep:buddy ..これはJ2MEコードです...アンドロイドコードではありません.. –