我在写一个应用程序,我正在使用Http连接在服务器上发布数据。当我在模拟器中检查它时,我的应用程序工作正常。我的Web服务花费太多时间来生成响应,我的模拟器也以正确的方式响应。不知何故,当我在设备上安装应用程序时,我的应用程序在服务器上发布了两次数据。我检查了它...有没有人有任何解决方案如何摆脱这?HTTP连接发布数据两次
在这里,我附上了我的发送请求的代码。我认为移动应用程序在达到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 2012-02-27 21:19:05
没有一个更全面的代码引用我会同意thinksteep的评论尽可能原因 – Kerry 2012-02-27 22:33:31
@thinksteep:好友..这是j2me代码..不是一个Android代码,.. – 2012-02-28 06:24:36