Error send data to webform
-
when send data to web form then throws exception android.os.NetworkOnMainThreadException I do not what misstask. Somebody help me Here my code: I have asp page in address http://tracklocation.somee.com/Default.aspx[^] private String SendData(){ String page=""; try { try { sVariable = URLEncoder.encode("id;96.2122;106.12343", "UTF-8"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } URI tURI = new URI("http://tracklocation.somee.com/Default.aspx"); HttpClient httpClient = new DefaultHttpClient(); HttpGet pageGet = new HttpGet(tURI); HttpPost pagePost = new HttpPost(tURI); HttpResponse response = httpClient.execute(pagePost); } catch (ClientProtocolException e) { e.printStackTrace(); return page; } catch (IOException e) { e.printStackTrace(); return page; } catch (Exception e) { e.printStackTrace(); page = e.toString(); } return page; }
-
when send data to web form then throws exception android.os.NetworkOnMainThreadException I do not what misstask. Somebody help me Here my code: I have asp page in address http://tracklocation.somee.com/Default.aspx[^] private String SendData(){ String page=""; try { try { sVariable = URLEncoder.encode("id;96.2122;106.12343", "UTF-8"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } URI tURI = new URI("http://tracklocation.somee.com/Default.aspx"); HttpClient httpClient = new DefaultHttpClient(); HttpGet pageGet = new HttpGet(tURI); HttpPost pagePost = new HttpPost(tURI); HttpResponse response = httpClient.execute(pagePost); } catch (ClientProtocolException e) { e.printStackTrace(); return page; } catch (IOException e) { e.printStackTrace(); return page; } catch (Exception e) { e.printStackTrace(); page = e.toString(); } return page; }
Here you could find answer. Clickety[^]
thatraja
Code converters | Education Needed No thanks, I am all stocked up. - Luc Pattyn When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
-
when send data to web form then throws exception android.os.NetworkOnMainThreadException I do not what misstask. Somebody help me Here my code: I have asp page in address http://tracklocation.somee.com/Default.aspx[^] private String SendData(){ String page=""; try { try { sVariable = URLEncoder.encode("id;96.2122;106.12343", "UTF-8"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } URI tURI = new URI("http://tracklocation.somee.com/Default.aspx"); HttpClient httpClient = new DefaultHttpClient(); HttpGet pageGet = new HttpGet(tURI); HttpPost pagePost = new HttpPost(tURI); HttpResponse response = httpClient.execute(pagePost); } catch (ClientProtocolException e) { e.printStackTrace(); return page; } catch (IOException e) { e.printStackTrace(); return page; } catch (Exception e) { e.printStackTrace(); page = e.toString(); } return page; }
Hi, Here u need asynctask Class. Because the above code that is working on Main Thread. Normally when u request from client to particular url it will take some time for getting response.in this time the entire work is depend on Main Thread. So Better touse Asynctask class.