0

I was building an enquiry to google's direction service, but the execute method crashed halfway, Here's the code

Uri.Builder b = Uri.parse("http://maps.googleapis.com/maps/api/directions/json").buildUpon();

                b.appendQueryParameter("origin", "The University of Hong KOng");
                b.appendQueryParameter("destination", "Lee Hysan Hall");
                b.appendQueryParameter("sensor", "false");
                b.appendQueryParameter("language", "en_US");

                String finalstr = b.build().toString();

                URI googledirectionservice = new URI(finalstr); 

                HttpGet mRequest = new HttpGet(googledirectionservice);
                HttpClient mClient = new DefaultHttpClient();

                response = mClient.execute(mRequest);

The url constructed is fine when I access it from my browser, but it wouldn't work accessed from the HttpClient.You can double check with

http://maps.googleapis.com/maps/api/directions/json?origin=The%20University%20of%20Hong%20KOng&destination=Lee%20Hysan%20Hall&sensor=false&language=en_US

What would be the reason? Besides, how can I make the debugging information more informative? The current ones in logcat showed nothing more than

threadid=... thread exiting with uncaught exception
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
Daniel
  • 1,484
  • 5
  • 24
  • 42

1 Answers1

0

try turning on logging in your client. instructions sample here or here

Access to the WIRE logs and to the HEADER logs is a must in developing networked apps. So, depending on the client you are using for your http implementation, you should google until you know how to expose the appropriate logs. If you have the logs for WIRE and for HEADERS, answers to questions like you post will be pretty much self-evident in the log details.

In my case, i just keep available an extra jar file built with my http implementation with the logs activated and when i need to debug the network, i just rebuild my app with that jar. It all depends on which http lib you have chosen.

list of libs:

loopj

volley

Community
  • 1
  • 1
Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43
  • great pointers, I will save it in case it's useful in the future. For now, moving code off the UI thread fixed everything. Anyway, thanks all the same! – Daniel Oct 25 '13 at 15:39