【发布时间】:2012-01-12 09:57:00
【问题描述】:
以下代码在 android 中不起作用
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
HttpClient httpclient = new DefaultHttpClient();
String url = "";
url = "http://bouncemeinws.cloudapp.net/BounceMeInWebService.asmx/GetAllMerchantNotification";
String url1= "http://182.71.82.154/BounceMeInWS/BounceMeInWebService.asmx/GetAllMerchantNotification";
HttpPost httppost = new HttpPost(url);
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("UserID", "130"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
System.out.println("status code--->"+ response.getStatusLine().getStatusCode());
// HttpEntity responseEntity = response.getEntity();
InputStream in = response.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer responseString = new StringBuffer("");
String line;
while ((line = reader.readLine()) != null) {
responseString.append(line + "\n");
}
System.out.println("response is -->" + responseString.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
运行时错误体 {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:黑色;margin-top:-5px}b {font-family:"Verdana";font-weight:bold;color:black;margin-top:-5px}H1 {font-family:"Verdana";font-weight:正常;字体大小:18pt;颜色:红色 }H2 { 字体家族:“Verdana”;字体粗细:正常;字体大小:14pt;颜色:栗色 }pre {字体家族:“Lucida Console”;字体-size:.9em} .marker {字体粗细:粗体;颜色:黑色;文字装饰:无;}.version {颜色:灰色;} .error {margin-bottom: 10px;}.expandable { text-decoration:underline;字体粗细:粗体;颜色:海军蓝;光标:手; }
“/”应用程序中的服务器错误。
运行时错误
描述:服务器上出现应用程序错误。此应用程序的当前自定义错误设置可防止远程查看应用程序错误的详细信息(出于安全原因)。但是,本地服务器计算机上运行的浏览器可以查看它。详细信息:要使此特定错误消息的详细信息可以在远程计算机上查看,请创建一个
<pre> <!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration></pre> 注意:您看到的当前错误页面可以被替换通过修改应用程序的
<!-- Web.Config Configuration File ->
<configuration> <system.web><customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/></system.web> </configuration>
【问题讨论】:
-
欢迎来到 SO! - “不工作”???来吧,我们需要更多细节。例外?日志猫?错误描述?
-
可能是因为尝试从
onCreate(...)的网络下载东西而导致 ANR,但正如 Guillaume 所说 - 我们需要更多详细信息。