Android 不在设备和模拟器上工作

Android 不在设备和模拟器上工作,android,parsing,Android,Parsing,以下代码在android中不起作用 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); HttpClient httpclient = new DefaultHttpClient(); String url = ""; url = "http://bouncemeinws.

以下代码在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();
    }

}
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
HttpClient HttpClient=新的DefaultHttpClient();
字符串url=“”;
url=”http://bouncemeinws.cloudapp.net/BounceMeInWebService.asmx/GetAllMerchantNotification";              
字符串url1=”http://182.71.82.154/BounceMeInWS/BounceMeInWebService.asmx/GetAllMerchantNotification";      
HttpPost HttpPost=新的HttpPost(url);
试试{
List nameValuePairs=新的ArrayList(2);
添加(新的BasicNameValuePair(“UserID”,“130”));
setEntity(新的UrlEncodedFormEntity(nameValuePairs));
HttpResponse response=httpclient.execute(httppost);
System.out.println(“状态代码-->”+response.getStatusLine().getStatusCode());
//HttpEntity responseEntity=response.getEntity();
InputStream in=response.getEntity().getContent();
BufferedReader reader=新的BufferedReader(新的InputStreamReader(in));
StringBuffer responseString=新的StringBuffer(“”);
弦线;
而((line=reader.readLine())!=null){
responseString.append(第+行“\n”);
}
System.out.println(“响应为-->”+responseString.toString());
}捕获(例外e){
e、 printStackTrace();
}
}
运行时错误正文{font-family:“Verdana”;font-weight:normal;font-size:.7em;颜色:黑色;}p{font-family:“Verdana”;font-weight:normal;font-weight:normal;font-weight:normal;}p{font-family:“Verdana”;font-weight:normal;font-size:黑色;margin-top:-5px}H1{font-family:“Verdana”;字体大小:18pt;颜色:红色}H2{font-family:“Verdana”;字体大小:正常;字体大小:14pt;颜色:褐红色}前{字体系列:“Lucida控制台”;字体大小:.9em}。标记{字体大小:粗体;颜色:黑色;文本装饰:无;}。版本{颜色:灰色;} .error{margin bottom:10px;}。可扩展的{文本装饰:下划线;字体大小:粗体;颜色:深蓝色;光标:手;}应用程序“/”中的服务器错误。运行时错误描述:服务器上发生应用程序错误。此应用程序的当前自定义错误设置阻止远程查看应用程序错误的详细信息(出于安全原因)。但是,本地服务器计算机上运行的浏览器可以查看此错误消息。

详细信息:要使此特定错误消息的详细信息在远程计算机上可见,请在位于当前web应用程序根目录中的“web.config”配置文件中创建一个标记。然后,此标记的“模式”属性应设置为“关闭”。



注意:通过修改应用程序配置标记的“defaultRedirect”属性以指向自定义错误页面URL,可以将当前看到的错误页面替换为自定义错误页面。

让我猜一猜:您在姜饼或Android 3上+

<!-- Web.Config Configuration File -> <configuration> <system.web><customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/></system.web> </configuration> 在这种情况下,系统只是杀死你的应用程序,因为你在UI线程中执行网络IO


请参见例如…

欢迎来到SO!-“不工作”???来吧,我们需要更多的细节。例外LogCat?错误描述?可能是因为试图在
onCreate(…)
中从网上下载内容,但正如纪尧姆所说,我们需要更多细节。 <!-- Web.Config Configuration File -> <configuration> <system.web><customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/></system.web> </configuration>