Hi all, I am having difficulty retrieving data from the internet to be displayed in a TextView. When I run the application it says the application has stopped unexpectedly. I am using the code:
String urls = "http://www.indulec.ie/weather.txt"; HttpClient client = new DefaultHttpClient(); // Create a method instance. HttpGet method = new HttpGet(urls); method.getParams().setIntParameter (CoreConnectionPNames.CONNECTION_TIMEOUT, 10000 ); method.getParams().setIntParameter (CoreConnectionPNames.SO_TIMEOUT, 10000 ); method.getParams().setIntParameter (CoreConnectionPNames.SOCKET_BUFFER_SIZE, 200000 ); method.getParams().setIntParameter (ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, 5 ); method.getParams().setIntParameter (ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 10 ); HttpResponse response = null; InputStream input = null; try { response = client.execute( method ); HttpEntity entity = response.getEntity(); input = entity.getContent(); TextView tv = (TextView)findViewById(R.id.somenews); tv.setText((CharSequence) input); setContentView(R.layout.latestnews); } catch ( IOException e ) { Log.d("", "Can not connect to the target server!" ); try { throw new IOException(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } finally { Log.d("", "close Expired Connections!" ); client.getConnectionManager().closeExpiredConnections (); } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

