Advertisement
dahomee_69

Untitled

Apr 11th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public static void sendRequest() throws ParseException, JSONException
  2. {
  3. try {
  4. String Service = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=24.698884,46.717719&radius=50000&language=ar&types=food&sensor=true&key=AIzaSyDuQJDY4Ym5CgyDdUa7s6TQzO5wKRKFrgE";
  5. URL url = new URL(Service);
  6. BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
  7. String line;
  8. StringBuffer response = new StringBuffer();
  9. line = reader.readLine();
  10.  
  11. while ((line = reader.readLine()) != null) {
  12.  
  13. System.out.println(line);
  14.  
  15. JSONParser jsonParser = new JSONParser();
  16. JSONObject jsonObject = (JSONObject) jsonParser.parse(line);
  17.  
  18. String name = (String) jsonObject.get("name");
  19. String vicinity = (String) jsonObject.get("vicinity");
  20. String icon = (String) jsonObject.get("icon");
  21. long rating= (long)jsonObject.get("rating");
  22.  
  23. }
  24. reader.close();
  25.  
  26. } catch (MalformedURLException e) {
  27. e.printStackTrace() ;
  28. } catch (IOException e) {
  29. e.printStackTrace() ;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement