Now Loading. Please Wait ...                Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
• Ecrair/Froyo                       Apache HTTP Client           • Gingerbread        HttpURLConnection            API   ...
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
oogle Maps API                                 Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
Re:Kayo-System Co.,Ltd.2012   2   15
package jp.co.kayo.android.localplayer.ds.ampache.test;  import   java.io.BufferedReader;  import   java.io.IOException;  ...
Re:Kayo-System Co.,Ltd.2012   2   15
try {           URI uri = new URI("http://maps.google.com/maps/api/geocode/json?address=".concat(                   URLEnc...
StringBuilder json = new StringBuilder();       String line;       while ((line = reader.readLine()) != null) {           ...
{       "long_name" : "           ",       "short_name" : "           ",       "types" : [ "locality", "political" ]      ...
private void printAddress(String str){           try {               JSONObject json = new JSONObject(str);               ...
Re:Kayo-System Co.,Ltd.2012   2   15
Upcoming SlideShare
Loading in...5
×

AndroidからWebサービスを使う

5,479

Published on

Published in: Technology, Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,479
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
29
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

AndroidからWebサービスを使う

  1. 1. Now Loading. Please Wait ... Re:Kayo-System Co.,Ltd.2012 2 15
  2. 2. Re:Kayo-System Co.,Ltd.2012 2 15
  3. 3. Re:Kayo-System Co.,Ltd.2012 2 15
  4. 4. Re:Kayo-System Co.,Ltd.2012 2 15
  5. 5. Re:Kayo-System Co.,Ltd.2012 2 15
  6. 6. Re:Kayo-System Co.,Ltd.2012 2 15
  7. 7. Re:Kayo-System Co.,Ltd.2012 2 15
  8. 8. Re:Kayo-System Co.,Ltd.2012 2 15
  9. 9. Re:Kayo-System Co.,Ltd.2012 2 15
  10. 10. Re:Kayo-System Co.,Ltd.2012 2 15
  11. 11. Re:Kayo-System Co.,Ltd.2012 2 15
  12. 12. Re:Kayo-System Co.,Ltd.2012 2 15
  13. 13. Re:Kayo-System Co.,Ltd.2012 2 15
  14. 14. Re:Kayo-System Co.,Ltd.2012 2 15
  15. 15. Re:Kayo-System Co.,Ltd.2012 2 15
  16. 16. Re:Kayo-System Co.,Ltd.2012 2 15
  17. 17. Re:Kayo-System Co.,Ltd.2012 2 15
  18. 18. Re:Kayo-System Co.,Ltd.2012 2 15
  19. 19. Re:Kayo-System Co.,Ltd.2012 2 15
  20. 20. Re:Kayo-System Co.,Ltd.2012 2 15
  21. 21. • Ecrair/Froyo Apache HTTP Client • Gingerbread HttpURLConnection API Android • HttpURLConnection Re:Kayo-System Co.,Ltd.2012 2 15
  22. 22. Re:Kayo-System Co.,Ltd.2012 2 15
  23. 23. Re:Kayo-System Co.,Ltd.2012 2 15
  24. 24. Re:Kayo-System Co.,Ltd.2012 2 15
  25. 25. Re:Kayo-System Co.,Ltd.2012 2 15
  26. 26. oogle Maps API Re:Kayo-System Co.,Ltd.2012 2 15
  27. 27. Re:Kayo-System Co.,Ltd.2012 2 15
  28. 28. Re:Kayo-System Co.,Ltd.2012 2 15
  29. 29. Re:Kayo-System Co.,Ltd.2012 2 15
  30. 30. Re:Kayo-System Co.,Ltd.2012 2 15
  31. 31. Re:Kayo-System Co.,Ltd.2012 2 15
  32. 32. Re:Kayo-System Co.,Ltd.2012 2 15
  33. 33. Re:Kayo-System Co.,Ltd.2012 2 15
  34. 34. Re:Kayo-System Co.,Ltd.2012 2 15
  35. 35. package jp.co.kayo.android.localplayer.ds.ampache.test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URLEncoder; import android.test.AndroidTestCase; import android.util.Log; public class MapAPITest extends AndroidTestCase { final String TAG = "MapAPI Test"; public void testCallService() { try { URI uri = new URI("http://maps.google.com/maps/api/geocode/json?address=".concat( URLEncoder.encode(" ")).concat("&sensor=false")); HttpURLConnection con = (HttpURLConnection) uri.toURL().openConnection(); InputStream is = con.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line; while ((line = reader.readLine()) != null) { Log.d("", line); } is.close(); reader.close(); } catch (URISyntaxException e) { Log.d(TAG, "URI Syntax error", e); } catch (MalformedURLException e) { Log.d(TAG, "URL Malformed Error", e); } catch (IOException e) { Log.d(TAG, "IO error", e); } } } Re:Kayo-System Co.,Ltd.2012 2 15
  36. 36. Re:Kayo-System Co.,Ltd.2012 2 15
  37. 37. try { URI uri = new URI("http://maps.google.com/maps/api/geocode/json?address=".concat( URLEncoder.encode(" ")).concat("&sensor=false")); HttpURLConnection con = (HttpURLConnection) uri.toURL().openConnection(); InputStream is = con.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder json = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { Log.d("", line); json.append(line); } is.close(); reader.close(); } catch (URISyntaxException e) { Log.d(TAG, "URI Syntax error", e); } catch (MalformedURLException e) { Log.d(TAG, "URL Malformed Error", e); } catch (IOException e) { Log.d(TAG, "IO error", e); } Re:Kayo-System Co.,Ltd.2012 2 15
  38. 38. StringBuilder json = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { Log.d("", line); json.append(line); } { "results" : [ { "address_components" : [ { "long_name" : " ", "short_name" : " ", "types" : [ "locality", "political" ] }, { "long_name" : " ", "short_name" : " ", "types" : [ "administrative_area_level_1", "political" ] }, Re:Kayo-System Co.,Ltd.2012 2 15
  39. 39. { "long_name" : " ", "short_name" : " ", "types" : [ "locality", "political" ] } "formatted_address" : " , ", "geometry" : { "bounds" : { "northeast" : { "lat" : 31.63195899999999, "lng" : 130.82772330 }, "southwest" : { "lat" : 31.41453820, "lng" : 130.68629260 } }, "location" : { "lat" : 31.49273440, "lng" : 130.70091430 }, Re:Kayo-System Co.,Ltd.2012 2 15
  40. 40. private void printAddress(String str){ try { JSONObject json = new JSONObject(str); JSONArray results = json.getJSONArray("results"); int count = results.length(); for(int i=0; i<count; i++){ JSONObject item = results.getJSONObject(i); String formatted_address = item.getString("formatted_address"); JSONObject geom = item.getJSONObject("geometry"); JSONObject location = geom.getJSONObject("location"); String lat = location.getString("lat"); String lng = location.getString("lng"); Log.d(TAG, "formatted_address"+ formatted_address); Log.d(TAG, "(lat, lng)="+lat+","+lng); } } catch (JSONException e) { Log.d(TAG, "Json Error", e); } } Re:Kayo-System Co.,Ltd.2012 2 15
  41. 41. Re:Kayo-System Co.,Ltd.2012 2 15
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×