Thanks for the help guys. I'm still having problems reading from the internet and also displaying the retreived content on a text file. Do you think it's a code problem or a firewall problem or am i missing some bit of code in the manifest to access the internet?
On Mar 11, 7:19 am, ku fu panda <ufinity0...@gmail.com> wrote: > public static InputStream getInputStreamWithHttpClient( String > resourceURL ) > throws IOException > { > // Create an instance of HttpClient. > HttpClient client = new DefaultHttpClient(); > // Create a method instance. > HttpGet method = new HttpGet( resourceURL ); > method.getParams().setIntParameter( > CoreConnectionPNames.CONNECTION_TIMEOUT, > CONNECTION_TINEOUT ); > method.getParams().setIntParameter > ( CoreConnectionPNames.SO_TIMEOUT, > CONNECTION_TINEOUT ); > method.getParams().setIntParameter( > CoreConnectionPNames.SOCKET_BUFFER_SIZE, IO_BUFFER_SIZE ); > 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(); > } > catch ( IOException e ) > { > Log.d( TAG, "Can not connect to the target server!" ); > throw new IOException(); > } > finally > { > Log.d( TAG, "close Expired Connections!" ); > client.getConnectionManager().closeExpiredConnections(); > } > return input; > } > > On Mar 10, 12:21 pm, dillirao malipeddi <dillir...@arijasoft.com> > wrote: > > > > > public String get_DAtaFromWeb(String url_toconnect)//throws Exception > > { > > int connection_Timeout = 10000;// 10sec > > HttpParams my_httpParams = new BasicHttpParams();; > > HttpConnectionParams.setConnectionTimeout(my_httpParams,connection_Timeout); > > HttpConnectionParams.setSoTimeout(my_httpParams,connection_Timeout); > > > HttpClient httpclient = new DefaultHttpClient(my_httpParams); //get > > http client with given params > > String responseBody = null; > > > try > > { > > > HttpGet httpget = new HttpGet(url_Pls); > > > if(myDebug.debug_Log)Log.i("CONTENT GET","executing request " + > > httpget.getURI()); > > > // Create a response handler > > ResponseHandler<String> responseHandler = new BasicResponseHandler(); > > > responseBody = httpclient.execute(httpget, responseHandler); > > } > > catch(Exception e) > > { > > if(myDebug.debug_Log)Log.i("Exception","Http Connection"+e.toString()); > > } > > > String Content = responseBody; > > > if(myDebug.debug_Log)Log.i("","-------------START---------------------------"); > > if(myDebug.debug_Log)Log.i("Response",""+Content); > > > if(myDebug.debug_Log)Log.i("","---------------END-------------------------"); > > > return Content; > > > } > > > On Mon, Mar 9, 2009 at 4:53 PM, murphy <howt...@hotmail.com> wrote: > > > > Hi all, > > > > Was just wondering if anyone had any code samples about writing and > > > retrieving data from a website? I am currently creating an application > > > which populates its textviews by accessing information from an online > > > source. > > > > Thanks, Murphy. > > > -- > > Dilli Rao. M- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---