AndroidからWebサービスを使う
Upcoming SlideShare
Loading in...5
×
 

AndroidからWebサービスを使う

on

  • 5,190 views

 

Statistics

Views

Total Views
5,190
Views on SlideShare
5,184
Embed Views
6

Actions

Likes
3
Downloads
27
Comments
0

3 Embeds 6

http://us-w1.rockmelt.com 3
http://www.verious.com 2
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    AndroidからWebサービスを使う AndroidからWebサービスを使う Presentation Transcript

    • 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 Android • HttpURLConnection 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
    • 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; 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
    • Re:Kayo-System Co.,Ltd.2012 2 15
    • 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
    • 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
    • { "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
    • 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
    • Re:Kayo-System Co.,Ltd.2012 2 15