1

I am requesting a HTTP request from Android Emulator but its getting failed .. Is there any issue with the emulator? I have also enabled internet connection permission from Manifest

  HttpClient Client = new DefaultHttpClient();

                // Create URL string

                 String URL = "http://androidexample.com/media/webservice/httpget.php?user="+loginValue+"&name="+fnameValue+"&email="+emailValue+"&pass="+passValue;

                //Log.i("httpget", URL);

               try
                {
                              String SetServerString = "";

                            // Create Request to server and get response

                              HttpGet httpget = new HttpGet(URL);
                             ResponseHandler<String> responseHandler = new BasicResponseHandler();
                             SetServerString = Client.execute(httpget, responseHandler);

                              // Show response on activity 

                             content.setText(SetServerString);
                 }
               catch(Exception ex)
                  {
                         content.setText("Fail!");
                   }
            }

I am using below link to test on emulator

http://androidexample.com/How_To_Make_HTTP_Get_Request_To_Server_-_Android_Example/index.php?view=article_discription&aid=63&aaid=88

Kara
  • 6,115
  • 16
  • 50
  • 57
user3226440
  • 559
  • 1
  • 8
  • 23
  • 2
    If it's getting failed then there should be a logcat output, check it out and post it here. – Paresh Mayani Apr 29 '14 at 04:43
  • it throus fail "error"... and from execute line – user3226440 Apr 29 '14 at 05:06
  • Include `logcat` output in your question. – Paresh Mayani Apr 29 '14 at 06:04
  • I suspect that you may be facing [NetworkOnMainThreadException](http://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception), but then that is just a possibility, out of many. Like suggested by others try including a complete trace of your logcat. – PCoder Apr 29 '14 at 13:21

0 Answers0