{"id":58,"date":"2017-12-22T15:25:01","date_gmt":"2017-12-22T14:25:01","guid":{"rendered":"https:\/\/www.cipv6.de\/worp\/?p=58"},"modified":"2017-12-22T15:31:15","modified_gmt":"2017-12-22T14:31:15","slug":"android-query-jso-data-log-the-response-to-logcat","status":"publish","type":"post","link":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/","title":{"rendered":"Android: Query JSON-Data , log the response to logcat"},"content":{"rendered":"<pre><\/pre>\n<p>[java]<br \/>\npackage de.clarisweb.android.jsondemo;<\/p>\n<p>import android.os.AsyncTask;<br \/>\nimport android.os.Bundle;<br \/>\nimport android.support.design.widget.FloatingActionButton;<br \/>\nimport android.support.design.widget.Snackbar;<br \/>\nimport android.support.v7.app.AppCompatActivity;<br \/>\nimport android.support.v7.widget.Toolbar;<br \/>\nimport android.util.Log;<br \/>\nimport android.view.View;<br \/>\nimport android.view.Menu;<br \/>\nimport android.view.MenuItem;<\/p>\n<p>import java.io.InputStream;<br \/>\nimport java.io.InputStreamReader;<br \/>\nimport java.net.HttpURLConnection;<br \/>\nimport java.net.URL;<\/p>\n<p>public class MainActivity extends AppCompatActivity {<\/p>\n<p>    public class DownloadTask extends AsyncTask&lt; String, Void, String&gt; {<\/p>\n<p>        @Override<br \/>\n        protected String doInBackground(String&#8230; urls) {<\/p>\n<p>            String result = &quot;&quot;;<br \/>\n            URL url;<br \/>\n            HttpURLConnection urlConnection= null;<\/p>\n<p>            try {<br \/>\n                url = new URL(urls[0]);<br \/>\n                urlConnection = (HttpURLConnection) url.openConnection();<br \/>\n                InputStream in = urlConnection.getInputStream();<br \/>\n                InputStreamReader reader = new InputStreamReader(in);<br \/>\n                int data = reader.read();<\/p>\n<p>                while (data != -1) {<br \/>\n                    char current = (char) data;<br \/>\n                    result += current;<br \/>\n                    data = reader.read();<\/p>\n<p>                }<\/p>\n<p>                    return result;<\/p>\n<p>            } catch  (Exception e){<\/p>\n<p>                e.printStackTrace();<br \/>\n                return null;<br \/>\n            }<br \/>\n        }<\/p>\n<p>        @Override<br \/>\n        protected void onPostExecute(String s) {<br \/>\n            super.onPostExecute(s);<\/p>\n<p>          Log.i (&quot;JSON: &quot;, s);<\/p>\n<p>        }<br \/>\n    }<\/p>\n<p>    @Override<br \/>\n    protected void onCreate(Bundle savedInstanceState) {<br \/>\n        super.onCreate(savedInstanceState);<br \/>\n        setContentView(R.layout.activity_main);<br \/>\n        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);<br \/>\n        setSupportActionBar(toolbar);<\/p>\n<p>        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);<br \/>\n        fab.setOnClickListener(new View.OnClickListener() {<br \/>\n            @Override<br \/>\n            public void onClick(View view) {<br \/>\n                Snackbar.make(view, &quot;Replace with your own action&quot;,Snackbar.LENGTH_LONG)<br \/>\n                        .setAction(&quot;Action&quot;, null).show();<\/p>\n<p>                            }<br \/>\n        });<\/p>\n<p>        DownloadTask task = new DownloadTask();<br \/>\n\/\/<br \/>\n        task.execute(&quot;http:\/\/headers.jsontest.com\/&quot;);<\/p>\n<p>    }<\/p>\n<p>    @Override<br \/>\n    public boolean onCreateOptionsMenu(Menu menu) {<br \/>\n        getMenuInflater().inflate(R.menu.menu_main, menu);<br \/>\n        return true;<br \/>\n    }<\/p>\n<p>    @Override<br \/>\n    public boolean onOptionsItemSelected(MenuItem item) {<br \/>\n         int id = item.getItemId();<\/p>\n<p>        if (id == R.id.action_settings) {<br \/>\n            return true;<br \/>\n        }<\/p>\n<p>        return super.onOptionsItemSelected(item);<br \/>\n    }<br \/>\n}<\/p>\n<p>[\/java]<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[java] package de.clarisweb.android.jsondemo; import android.os.AsyncTask; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import android.view.Menu; import android.view.MenuItem; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class MainActivity extends AppCompatActivity { public class DownloadTask extends AsyncTask&lt; String, Void, String&gt; { @Override protected String doInBackground(String&#8230; urls) { String result = &hellip; <a href=\"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Android: Query JSON-Data , log the response to logcat&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[39,59],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-android","tag-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android: Query JSON-Data , log the response to logcat - cipv6.de<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android: Query JSON-Data , log the response to logcat - cipv6.de\" \/>\n<meta property=\"og:description\" content=\"[java] package de.clarisweb.android.jsondemo; import android.os.AsyncTask; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import android.view.Menu; import android.view.MenuItem; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class MainActivity extends AppCompatActivity { public class DownloadTask extends AsyncTask&lt; String, Void, String&gt; { @Override protected String doInBackground(String&#8230; urls) { String result = &hellip; Continue reading &quot;Android: Query JSON-Data , log the response to logcat&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/\" \/>\n<meta property=\"og:site_name\" content=\"cipv6.de\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-22T14:25:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-22T14:31:15+00:00\" \/>\n<meta name=\"author\" content=\"ugu5ma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ugu5ma\" \/>\n<meta name=\"twitter:site\" content=\"@ugu5ma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ugu5ma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/\"},\"author\":{\"name\":\"ugu5ma\",\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/#\\\/schema\\\/person\\\/5d62b275485540be9e5e9e33d4fab86d\"},\"headline\":\"Android: Query JSON-Data , log the response to logcat\",\"datePublished\":\"2017-12-22T14:25:01+00:00\",\"dateModified\":\"2017-12-22T14:31:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/\"},\"wordCount\":277,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/#\\\/schema\\\/person\\\/5d62b275485540be9e5e9e33d4fab86d\"},\"keywords\":[\"Android\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/\",\"url\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/\",\"name\":\"Android: Query JSON-Data , log the response to logcat - cipv6.de\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/#website\"},\"datePublished\":\"2017-12-22T14:25:01+00:00\",\"dateModified\":\"2017-12-22T14:31:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/index.php\\\/2017\\\/12\\\/22\\\/android-query-jso-data-log-the-response-to-logcat\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android: Query JSON-Data , log the response to logcat\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/#website\",\"url\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/\",\"name\":\"cipv6.de\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/#\\\/schema\\\/person\\\/5d62b275485540be9e5e9e33d4fab86d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.cipv6.de\\\/worp\\\/#\\\/schema\\\/person\\\/5d62b275485540be9e5e9e33d4fab86d\",\"name\":\"ugu5ma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g\",\"caption\":\"ugu5ma\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/cipv6.de\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android: Query JSON-Data , log the response to logcat - cipv6.de","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/","og_locale":"en_US","og_type":"article","og_title":"Android: Query JSON-Data , log the response to logcat - cipv6.de","og_description":"[java] package de.clarisweb.android.jsondemo; import android.os.AsyncTask; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import android.view.Menu; import android.view.MenuItem; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class MainActivity extends AppCompatActivity { public class DownloadTask extends AsyncTask&lt; String, Void, String&gt; { @Override protected String doInBackground(String&#8230; urls) { String result = &hellip; Continue reading \"Android: Query JSON-Data , log the response to logcat\"","og_url":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/","og_site_name":"cipv6.de","article_published_time":"2017-12-22T14:25:01+00:00","article_modified_time":"2017-12-22T14:31:15+00:00","author":"ugu5ma","twitter_card":"summary_large_image","twitter_creator":"@ugu5ma","twitter_site":"@ugu5ma","twitter_misc":{"Written by":"ugu5ma","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/#article","isPartOf":{"@id":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/"},"author":{"name":"ugu5ma","@id":"https:\/\/www.cipv6.de\/worp\/#\/schema\/person\/5d62b275485540be9e5e9e33d4fab86d"},"headline":"Android: Query JSON-Data , log the response to logcat","datePublished":"2017-12-22T14:25:01+00:00","dateModified":"2017-12-22T14:31:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/"},"wordCount":277,"commentCount":0,"publisher":{"@id":"https:\/\/www.cipv6.de\/worp\/#\/schema\/person\/5d62b275485540be9e5e9e33d4fab86d"},"keywords":["Android"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/","url":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/","name":"Android: Query JSON-Data , log the response to logcat - cipv6.de","isPartOf":{"@id":"https:\/\/www.cipv6.de\/worp\/#website"},"datePublished":"2017-12-22T14:25:01+00:00","dateModified":"2017-12-22T14:31:15+00:00","breadcrumb":{"@id":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.cipv6.de\/worp\/index.php\/2017\/12\/22\/android-query-jso-data-log-the-response-to-logcat\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cipv6.de\/worp\/"},{"@type":"ListItem","position":2,"name":"Android: Query JSON-Data , log the response to logcat"}]},{"@type":"WebSite","@id":"https:\/\/www.cipv6.de\/worp\/#website","url":"https:\/\/www.cipv6.de\/worp\/","name":"cipv6.de","description":"","publisher":{"@id":"https:\/\/www.cipv6.de\/worp\/#\/schema\/person\/5d62b275485540be9e5e9e33d4fab86d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cipv6.de\/worp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.cipv6.de\/worp\/#\/schema\/person\/5d62b275485540be9e5e9e33d4fab86d","name":"ugu5ma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g","caption":"ugu5ma"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/7211dd31d32612293e4228c8f880721a803dcc15211868f096ea9a8e77b6f316?s=96&d=mm&r=g"},"sameAs":["https:\/\/cipv6.de"]}]}},"_links":{"self":[{"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":0,"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cipv6.de\/worp\/index.php\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}