我正在编写一个应用程序,其中我使用 Http Connection 在服务器上发布数据。当我在模拟器中检查它时,我的应用程序运行良好。我的 Web 服务花费了太多时间来生成响应,并且我的模拟器也以正确的方式响应。不知何故,当我在设备上安装应用程序时,我的应用程序在服务器上发布了两次数据。我已经检查过了......有没有人有任何关于如何摆脱这种情况的解决方案???
在这里,我附上了我的发送请求代码。我认为移动应用程序在达到 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());