Try putting it in onStartCommand() instead. I haven't had any problems doing posts from the service, but they all happen after the onCreate method.
On Nov 5, 8:38 pm, Burk Ferden <[email protected]> wrote: > Hello, > I am trying to do a http post to a php script. the method works if I > place it in the onCreate event of the application but gets a > ConnectionTimeOut error when it tries to execute it from the service. > Here is an example of my method > > String url = "http://myurl/" + > "?tmpl=javascript" + > "&mode=recieved" + > "&id=" + id; > URI uri = null; > try { > url = url.replace(" ", "%20"); > uri = new URI(url); > } catch (URISyntaxException e1) { > // TODO Auto-generated catch block > e1.printStackTrace(); > } > HttpGet httpGet = new HttpGet(uri); > HttpParams httpParameters = new BasicHttpParams(); > // Set the timeout in milliseconds until a connection is > established. > int timeoutConnection = 10000; > HttpConnectionParams.setConnectionTimeout(httpParameters, > timeoutConnection); > // Set the default socket timeout (SO_TIMEOUT) > // in milliseconds which is the timeout for waiting for data. > int timeoutSocket = 10000; > HttpConnectionParams.setSoTimeout(httpParameters, > timeoutSocket); > > DefaultHttpClient httpClient = new > DefaultHttpClient(httpParameters); > try { > HttpResponse response = httpClient.execute(httpGet); > } catch (ClientProtocolException e) { > System.out.println(e.getLocalizedMessage()); > e.printStackTrace(); > } catch (IOException e) { > System.out.println(e.getLocalizedMessage()); > e.printStackTrace(); > } > > I have no idea why the service would get a time out error but the > application activity would not. I am baffled. -- 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

