{"id":627,"date":"2017-02-22T00:00:15","date_gmt":"2017-02-21T21:00:15","guid":{"rendered":"http:\/\/delimuhendis.org\/?p=627"},"modified":"2022-12-20T21:32:53","modified_gmt":"2022-12-20T21:32:53","slug":"androidde-location-parsing-2","status":"publish","type":"post","link":"https:\/\/www.delimuhendis.org\/?p=627","title":{"rendered":"Android&#8217;de Location Parsing"},"content":{"rendered":"\n<p>Merhaba arkada\u015flar bug\u00fcn sizinle daha \u00f6nce yapm\u0131\u015f oldu\u011fumuz Android ile Konum Servisleri dersimizde elde etti\u011fimiz enlem ve boylam de\u011ferlerinden \u00dclke,Eyalet,\u015eehir gibi bilgilerin elde edilmesini sa\u011flayaca\u011f\u0131z. E\u011fer Android ile Konum Servisleri dersini takip etmediyseniz <a href=\"http:\/\/delimuhendis.org\/android-ile-konum-servisleri\/\"><strong>buradan<\/strong><\/a> ula\u015fabilirsiniz.<\/p>\n\n\n\n<p>\u015eimdi \u00f6ncelikle bu projede de ge\u00e7en projede yapt\u0131\u011f\u0131m\u0131z i\u015flemleri 2.defa yapmamak ad\u0131na s\u0131f\u0131rdan bir projeye ba\u015flamak yerine halen var olan proje i\u00e7inde g\u00fcncellemeler yaparak gidece\u011fiz.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"alignleft\"><a href=\"http:\/\/delimuhendis.org\/wp-content\/uploads\/2017\/02\/Ekran-Resmi-2017-02-22-00.53.20.png\"><img decoding=\"async\" src=\"http:\/\/delimuhendis.org\/wp-content\/uploads\/2017\/02\/Ekran-Resmi-2017-02-22-00.53.20-1024x640.png\" alt=\"\" class=\"wp-image-628\"\/><\/a><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">\u00a01)Layout Tasar\u0131m\u0131<\/h3>\n\n\n\n<p>\u00d6ncelikle Layout Dosyam\u0131z\u0131 a\u00e7\u0131yoruz ve layout dosyam\u0131z\u0131n i\u00e7indeki an leyout\u0131n i\u00e7ine \u015fu elementleri ekliyoruz.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;LinearLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"&gt;\n    &lt;TextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:id=\"@+id\/txtEnlem\"\n        android:textAlignment=\"center\"\n        android:textSize=\"21sp\"\n        android:textColor=\"#ffffff\"\/&gt;\n    &lt;TextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:id=\"@+id\/txtBoylam\"\n        android:textAlignment=\"center\"\n        android:textSize=\"21sp\"\n        android:textColor=\"#ffffff\"\/&gt;\n    &lt;TextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:id=\"@+id\/txtUlke\"\n        android:textAlignment=\"center\"\n        android:textSize=\"21sp\"\n        android:textColor=\"#ffffff\"\/&gt;\n    &lt;TextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:id=\"@+id\/txtSehir\"\n        android:textAlignment=\"center\"\n        android:textSize=\"21sp\"\n        android:textColor=\"#ffffff\"\/&gt;\n&lt;\/LinearLayout&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2)Kodlama<\/h3>\n\n\n\n<p>Ge\u00e7en dersimizde konum servislerini kullanarak enlem ve boylam de\u011ferlerini alm\u0131\u015ft\u0131k \u015fimdi ise o de\u011ferleri parse ederek \u00dclke ve \u015eehir bilgisi alaca\u011f\u0131z.<\/p>\n\n\n\n<p>\u00d6ncelikle activity s\u0131n\u0131f\u0131m\u0131z\u0131n hemen alt\u0131na global de\u011fi\u015fken olarak alttakileri ekliyoruz.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">TextView txtUlke,txtSehir;<\/pre>\n\n\n\n<p>Sonras\u0131nda ise onCreate methodunun i\u00e7ine alttaki sat\u0131rlar\u0131 ekliyoruz ve TextViewlerimizin birer nesnelerini yarat\u0131yoruz.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">txtUlke=(TextView)findViewById(R.id.txtUlke);\ntxtSehir=(TextView)findViewById(R.id.txtSehir);<\/pre>\n\n\n\n<p>\u015eimdi b\u00fct\u00fcn ayarlar tamamland\u0131. Art\u0131k ald\u0131\u011f\u0131m\u0131z enlem ve boylam de\u011ferlerini parse edebiliriz. Hat\u0131rlars\u0131n\u0131z ge\u00e7en derste onLocationChanged methodu ile her konum g\u00fcncellemesi ald\u0131\u011f\u0131m\u0131zda \u00e7al\u0131\u015ft\u0131r\u0131lacak kodlar\u0131 yazm\u0131\u015ft\u0131k. \u015eimdi bu methodun i\u00e7ine a\u015fa\u011f\u0131daki kodlar\u0131 ekleyece\u011fiz ve bu \u015fekilde her konum g\u00fcncellemesi ald\u0131\u011f\u0131m\u0131zda g\u00fcncel konumun enlem ve boylam de\u011ferlerini parse dip bulunulan \u00fclke ve \u015fehri ekrana yazd\u0131raca\u011f\u0131z.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">try\n{\n    Geocoder geocoder;\n    List&lt;Address&gt; addresses;\n    geocoder = new Geocoder(this, Locale.getDefault());\n\n    addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);\n    txtUlke.setText(\"\u00dclke:\"+addresses.get(0).getCountryName());\n    txtSehir.setText(\"\u015eehir:\"+addresses.get(0).getLocality());\n\n}\ncatch (Exception e)\n{\n    if(txtUlke.getText().toString()==null || txtUlke.getText().toString().equals(\"\"))\n    {\n        txtUlke.setText(\"Bilinmiyor\");\n    }\n    if(txtSehir.getText().toString()==null || txtSehir.getText().toString().equals(\"\"))\n    {\n        txtSehir.setText(\"Bilinmiyor\");\n    }\n    e.printStackTrace();\n}<\/pre>\n\n\n\n<p>Arkada\u015flar bu derste de elde etti\u011fimiz konum bilgileri \u00fczerinden detayl\u0131 adres bilgisi almay\u0131 i\u015fledik. Bol bol \u00f6rnek yapmay\u0131 unutmay\u0131n.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Merhaba arkada\u015flar bug\u00fcn sizinle daha \u00f6nce yapm\u0131\u015f oldu\u011fumuz Android ile Konum Servisleri dersimizde elde etti\u011fimiz enlem ve boylam de\u011ferlerinden \u00dclke,Eyalet,\u015eehir&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1409,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[40,237,363,450],"class_list":["post-627","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programlama","tag-android","tag-geocoder","tag-location","tag-parsing"],"_links":{"self":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts\/627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=627"}],"version-history":[{"count":2,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts\/627\/revisions"}],"predecessor-version":[{"id":1411,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/posts\/627\/revisions\/1411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=\/wp\/v2\/media\/1409"}],"wp:attachment":[{"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.delimuhendis.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}