SlideShare a Scribd company logo
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

More Related Content

KEY
Data Binding in qooxdoo
PDF
Tame Accidental Complexity with Ruby and MongoMapper
PPTX
Hacking MongoDB at RelateIQ, A Salesforce Company
PDF
はじめてのMongoDB
PDF
The Future of JavaScript (SXSW '07)
PDF
OSDC.fr 2012 :: Cascalog : progammation logique pour Hadoop
PDF
デブサミ2015 事例から学ぶAndroidアプリのセキュアコーディング「SSL/TLS証明書検証の現状と対策」
PDF
夜子まま塾講義3(androidで電卓アプリを作る)
Data Binding in qooxdoo
Tame Accidental Complexity with Ruby and MongoMapper
Hacking MongoDB at RelateIQ, A Salesforce Company
はじめてのMongoDB
The Future of JavaScript (SXSW '07)
OSDC.fr 2012 :: Cascalog : progammation logique pour Hadoop
デブサミ2015 事例から学ぶAndroidアプリのセキュアコーディング「SSL/TLS証明書検証の現状と対策」
夜子まま塾講義3(androidで電卓アプリを作る)

Similar to AndroidからWebサービスを使う (20)

PDF
I Don't Care About Security (And Neither Should You)
PDF
Vavr Java User Group Rheinland
PDF
I Don't Care About Security (And Neither Should You)
ODP
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
ODP
Intravert Server side processing for Cassandra
PPTX
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
PDF
Java EE 7 overview
PDF
Open Policy Agent (OPA) と Kubernetes Policy
PPT
Fantom and Tales
PDF
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
PDF
Open Policy Agent (OPA) 入門
PPTX
Grokking Grok: Monitorama PDX 2015
PDF
Middy.js - A powerful Node.js middleware framework for your lambdas​
PDF
Rails in the enterprise
PPT
WebSocket JSON Hackday
PDF
Rack Middleware
PDF
Coding Ajax
PDF
TPSE Thailand 2015 - Rethinking Web with React and Flux
PDF
No more Big Data Hacking—Time for a Complete ETL Solution with Oracle Data In...
I Don't Care About Security (And Neither Should You)
Vavr Java User Group Rheinland
I Don't Care About Security (And Neither Should You)
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
Intravert Server side processing for Cassandra
#ITsubbotnik Spring 2017: Roman Iovlev "Java edge in test automation"
Java EE 7 overview
Open Policy Agent (OPA) と Kubernetes Policy
Fantom and Tales
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Open Policy Agent (OPA) 入門
Grokking Grok: Monitorama PDX 2015
Middy.js - A powerful Node.js middleware framework for your lambdas​
Rails in the enterprise
WebSocket JSON Hackday
Rack Middleware
Coding Ajax
TPSE Thailand 2015 - Rethinking Web with React and Flux
No more Big Data Hacking—Time for a Complete ETL Solution with Oracle Data In...
Ad

More from Masafumi Terazono (20)

PDF
初心者向けSpigot開発
PPTX
Minecraft dayの報告
PPTX
BungeeCordeについて
PPTX
Spongeについて
PPTX
Kobe.py 勉強会 minecraft piスライド
PPTX
Minecraftと連携するSlackちゃんという会話Botを作った話
PDF
初心者〜中級者 Android StudioによるAndroid勉強会資料(スライド)
PDF
夜子まま塾 2015年1月23日 進行用資料
PDF
PDF
Android wear勉強会2
PDF
夜子まま塾@鹿児島
PDF
セーラーソン振り返り
PDF
関西Nfc lab勉強会 宣伝
PDF
関西支部 第二回 NFCLab勉強会 
PDF
日本Androidの会 中国支部資料
PDF
Android+NFC 日本Androidの会神戸支部 勉強会
PDF
関西支部Android勉強会(ロボットxnfc)
PDF
関西Unity勉強会
PDF
夜子まま塾講義12(broadcast reciever)
PDF
夜子まま塾講義11(暗黙的intent)
初心者向けSpigot開発
Minecraft dayの報告
BungeeCordeについて
Spongeについて
Kobe.py 勉強会 minecraft piスライド
Minecraftと連携するSlackちゃんという会話Botを作った話
初心者〜中級者 Android StudioによるAndroid勉強会資料(スライド)
夜子まま塾 2015年1月23日 進行用資料
Android wear勉強会2
夜子まま塾@鹿児島
セーラーソン振り返り
関西Nfc lab勉強会 宣伝
関西支部 第二回 NFCLab勉強会 
日本Androidの会 中国支部資料
Android+NFC 日本Androidの会神戸支部 勉強会
関西支部Android勉強会(ロボットxnfc)
関西Unity勉強会
夜子まま塾講義12(broadcast reciever)
夜子まま塾講義11(暗黙的intent)
Ad

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Spectroscopy.pptx food analysis technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Big Data Technologies - Introduction.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPT
Teaching material agriculture food technology
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Unlocking AI with Model Context Protocol (MCP)
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectroscopy.pptx food analysis technology
Network Security Unit 5.pdf for BCA BBA.
Big Data Technologies - Introduction.pptx
Review of recent advances in non-invasive hemoglobin estimation
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Teaching material agriculture food technology
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
Spectral efficient network and resource selection model in 5G networks
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Unlocking AI with Model Context Protocol (MCP)

AndroidからWebサービスを使う