{"id":317,"date":"2010-10-24T14:17:00","date_gmt":"2010-10-24T14:17:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/android-full-app-part-2-using-the-http-api.html"},"modified":"2012-10-21T19:20:30","modified_gmt":"2012-10-21T19:20:30","slug":"android-full-app-part-2-using-http-api","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html","title":{"rendered":"Android Full App, Part 2: Using the HTTP API"},"content":{"rendered":"<p>This is the second part of the <a href=\"http:\/\/www.javacodegeeks.com\/2010\/10\/android-full-application-tutorial.html\">\u201cAndroid Full Application Tutorial\u201d series<\/a>. The complete application aims to provide an easy way of performing movies\/actors searching over the internet. In the first part of the series (<a href=\"http:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-1-main-activity.html\">\u201cMain Activity UI\u201d<\/a>), we created the Eclipse project and set up a basic interface for the main activity of the application. In this part we are going to see how to consume an external HTTP API and how to integrate the API&#8217;s searching capabilities into our application.<\/p>\n<p>For the movies and actor look-ups we will be using the <a href=\"http:\/\/api.themoviedb.org\/2.1\">TMDb API<\/a>. From the official site:<br \/>\n<span style=\"font-style: italic\">\u201cThe TMDb API is a powerful resource for any developers that want to integrate movie &amp; cast data along with posters or movie fanart. All of the API methods are available in XML, YAML and JSON.\u201d<\/span><\/p>\n<p>As with most available APIs, you are going to need a valid key in order to be able to use the API. The first step for that is to create a free account at <a href=\"http:\/\/www.themoviedb.org\/account\/signup\">TMDb&#8217;s Sign-Up page<\/a>. After signing up, log into your account and find the link for generating an API key.<\/p>\n<p>The list of the available API methods can be found at the <a href=\"http:\/\/api.themoviedb.org\/2.1\">TMDb API documentation page<\/a> and the most important ones are the following:<\/p>\n<ul>\n<li><a href=\"http:\/\/api.themoviedb.org\/2.1\/methods\/Movie.search\">Movie.search<\/a>: Provides the easiest and quickest way to search for a movie.<\/li>\n<li><a href=\"http:\/\/api.themoviedb.org\/2.1\/methods\/Person.search\">Person.search<\/a>: Is used to search for an actor, actress or production member.<\/li>\n<\/ul>\n<p>For movies search, the example URL is the following:<\/p>\n<p><a href=\"http:\/\/api.themoviedb.org\/2.1\/Movie.search\/en\/xml\/APIKEY\/Transformers\">http:\/\/api.themoviedb.org\/2.1\/Movie.search\/en\/xml\/APIKEY\/Transformers<\/a><\/p>\n<p>For people search, the example URL is the following:<\/p>\n<p><a href=\"http:\/\/api.themoviedb.org\/2.1\/Person.search\/en\/xml\/APIKEY\/Brad+Pitt\">http:\/\/api.themoviedb.org\/2.1\/Person.search\/en\/xml\/APIKEY\/Brad+Pitt<\/a><\/p>\n<p>(where APIKEY has to be replaced with a valid API key)<\/p>\n<p>As you can see, the API is pretty easy and straightforward to use. It only involves performing HTTP GET requests at a specific URL and then retrieving the responses into a predefined format.<\/p>\n<p>Next, we are going to see how to leverage Android&#8217;s networking capabilities in order to consume the API and provide a presentation of the provided data. Note that we will use the XML format for the responses, but this will be showcased in a next tutorial.<\/p>\n<p>For manipulating HTTP requests\/responses in an Android environment, the standard classes from the <a href=\"http:\/\/developer.android.com\/reference\/java\/net\/package-summary.html\">java.net<\/a> package can be used. Thus, classes such as <a href=\"http:\/\/developer.android.com\/reference\/java\/net\/URL.html\">URL<\/a>, <a href=\"http:\/\/developer.android.com\/reference\/java\/net\/URLConnection.html\">URLConnection<\/a>, <a href=\"http:\/\/developer.android.com\/reference\/java\/net\/HttpURLConnection.html\">HttpURLConnection<\/a> etc., can all be used in the known way. However, you can avoid dealing with the low level details by using the Apache HTTP Client libraries. This library is based in the well known <a href=\"http:\/\/hc.apache.org\/\">Apache Commons HTTP Client<\/a> framework.<\/p>\n<p>Let&#8217;s get started with the code. We will create a class named \u201cHttpRetriever\u201d which will be responsible for performing all the HTTP requests and will return the responses both in text format and as a stream (for image manipulation). The code for this class is the following:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.apps.moviesearchapp.services;\r\n\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\n\r\nimport org.apache.http.HttpEntity;\r\nimport org.apache.http.HttpResponse;\r\nimport org.apache.http.HttpStatus;\r\nimport org.apache.http.client.methods.HttpGet;\r\nimport org.apache.http.impl.client.DefaultHttpClient;\r\nimport org.apache.http.util.EntityUtils;\r\n\r\nimport android.graphics.Bitmap;\r\nimport android.graphics.BitmapFactory;\r\nimport android.util.Log;\r\n\r\nimport com.javacodegeeks.android.apps.moviesearchapp.io.FlushedInputStream;\r\nimport com.javacodegeeks.android.apps.moviesearchapp.util.Utils;\r\n\r\npublic class HttpRetriever {\r\n   \r\n   private DefaultHttpClient client = new DefaultHttpClient();   \r\n   \r\n   public String retrieve(String url) {\r\n      \r\n        HttpGet getRequest = new HttpGet(url);\r\n        \r\n      try {\r\n         \r\n         HttpResponse getResponse = client.execute(getRequest);\r\n         final int statusCode = getResponse.getStatusLine().getStatusCode();\r\n         \r\n         if (statusCode != HttpStatus.SC_OK) { \r\n            Log.w(getClass().getSimpleName(), \"Error \" + statusCode + \" for URL \" + url); \r\n            return null;\r\n         }\r\n         \r\n         HttpEntity getResponseEntity = getResponse.getEntity();\r\n         \r\n         if (getResponseEntity != null) {\r\n            return EntityUtils.toString(getResponseEntity);\r\n         }\r\n         \r\n      } \r\n      catch (IOException e) {\r\n         getRequest.abort();\r\n         Log.w(getClass().getSimpleName(), \"Error for URL \" + url, e);\r\n      }\r\n      \r\n      return null;\r\n      \r\n   }\r\n   \r\n   public InputStream retrieveStream(String url) {\r\n      \r\n      HttpGet getRequest = new HttpGet(url);\r\n        \r\n      try {\r\n         \r\n         HttpResponse getResponse = client.execute(getRequest);\r\n         final int statusCode = getResponse.getStatusLine().getStatusCode();\r\n         \r\n         if (statusCode != HttpStatus.SC_OK) { \r\n            Log.w(getClass().getSimpleName(), \"Error \" + statusCode + \" for URL \" + url); \r\n            return null;\r\n         }\r\n\r\n         HttpEntity getResponseEntity = getResponse.getEntity();\r\n         return getResponseEntity.getContent();\r\n         \r\n      } \r\n      catch (IOException e) {\r\n         getRequest.abort();\r\n         Log.w(getClass().getSimpleName(), \"Error for URL \" + url, e);\r\n      }\r\n      \r\n      return null;\r\n      \r\n   }\r\n   \r\n   public Bitmap retrieveBitmap(String url) throws Exception {\r\n      \r\n      InputStream inputStream = null;\r\n      try {\r\n         inputStream = this.retrieveStream(url);\r\n         final Bitmap bitmap = BitmapFactory.decodeStream(new FlushedInputStream(inputStream));\r\n         return bitmap;\r\n      } \r\n      finally {\r\n         Utils.closeStreamQuietly(inputStream);\r\n      }\r\n      \r\n   }\r\n\r\n}\r\n<\/pre>\n<p>For the actual execution of the HTTP requests, we are using an instance of the <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/impl\/client\/DefaultHttpClient.html\">DefaultHttpClient<\/a> class, which, as its name implies, is the default implementation of an HTTP client, i.e. the default implementation of the <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/client\/HttpClient.html\">HttpClient<\/a> interface. We also use the <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/client\/methods\/HttpGet.html\">HttpGet<\/a> class (in order to represent a GET request) and provide the target URL for its constructor argument. The HTTP client executes the request and provides an <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/HttpResponse.html\">HttpResponse<\/a> object which contains the actual server response along with any other information. For example, we can retrieve the response status code and compare it against the code for <a href=\"http:\/\/en.wikipedia.org\/wiki\/List_of_HTTP_status_codes#2xx_Success\">successful HTTP requests<\/a> (<a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/HttpStatus.html#SC_OK\">HttpStatus.SC_OK<\/a>). For successful requests, we take reference of the enclosed <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/HttpEntity.html\">HttpEntity<\/a> object and from that we have access to the actual response data. For textual responses we convert the entity to a String using the static <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/util\/EntityUtils.html#toString%28org.apache.http.HttpEntity%29\">toString<\/a> method of the <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/util\/EntityUtils.html\">EntityUtils<\/a> class. If we wish to retrieve the data as a byte stream (for example in order to handle binary downloads), we use the <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/HttpEntity.html#getContent%28%29\">getContent<\/a> method of the <a href=\"http:\/\/developer.android.com\/reference\/org\/apache\/http\/HttpEntity.html\">HttpEntity<\/a> class, which creates a new <a href=\"http:\/\/developer.android.com\/reference\/java\/io\/InputStream.html\">InputStream<\/a> object of the entity.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Note that there is also a third method for directly returning <a href=\"http:\/\/developer.android.com\/reference\/android\/graphics\/Bitmap.html\">Bitmap<\/a> objects. This will be helpful at the later parts of the tutorial series, where we will be downloading images from the internet. In that method, we execute the GET request and retrieve an <a href=\"http:\/\/developer.android.com\/reference\/java\/io\/InputStream.html\">InputStream<\/a> as usual. Then, we use the <a href=\"http:\/\/developer.android.com\/reference\/android\/graphics\/BitmapFactory.html#decodeStream%28java.io.InputStream%29\">decodeStream<\/a> method of the <a href=\"http:\/\/developer.android.com\/reference\/android\/graphics\/BitmapFactory.html\">BitmapFactory<\/a> class to create a new Bitmap object. Note that we do not directly provide the downloaded <a href=\"http:\/\/developer.android.com\/reference\/java\/io\/InputStream.html\">InputStream<\/a>, but we first wrap it with a FlushedInputStream class. As mentioned at the <a href=\"http:\/\/android-developers.blogspot.com\/2010\/07\/multithreading-for-performance.html\">official Android developers blog post<\/a>, there is a bug in the previous versions of the <a href=\"http:\/\/developer.android.com\/reference\/android\/graphics\/BitmapFactory.html#decodeStream%28java.io.InputStream%29\">decodeStream<\/a> method that may cause problems when downloading an image over a slow connection. The custom class FlushedInputStream, which extends <a href=\"http:\/\/developer.android.com\/reference\/java\/io\/FilterInputStream.html\">FilterInputStream<\/a>, is used instead in order to fix the problem. The code for that class is the following:<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.apps.moviesearchapp.io;\r\n\r\nimport java.io.FilterInputStream;\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\n\r\npublic class FlushedInputStream extends FilterInputStream {\r\n \r\n    public FlushedInputStream(InputStream inputStream) {\r\n        super(inputStream);\r\n    }\r\n\r\n    @Override\r\n    public long skip(long n) throws IOException {\r\n        long totalBytesSkipped = 0L;\r\n        while (totalBytesSkipped &lt; n) {\r\n            long bytesSkipped = in.skip(n - totalBytesSkipped);\r\n            if (bytesSkipped == 0L) {\r\n                  int b = read();\r\n                  if (b &lt; 0) {\r\n                      break;  \/\/ we reached EOF\r\n                  } else {\r\n                      bytesSkipped = 1; \/\/ we read one byte\r\n                  }\r\n           }\r\n            totalBytesSkipped += bytesSkipped;\r\n        }\r\n        return totalBytesSkipped;\r\n    }\r\n    \r\n}\r\n<\/pre>\n<p>This ensures that skip() actually skips the provided number of bytes, unless we reach the end of file.  Finally, we use the closeStreamQuietly method of a custom Utils class in order to handle exceptions  which might occur when closing an <a href=\"http:\/\/developer.android.com\/reference\/java\/io\/InputStream.html\">InputStream<\/a>. The code is as follows:  <\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.apps.moviesearchapp.util;\r\n\r\nimport java.io.IOException;\r\nimport java.io.InputStream;\r\n\r\npublic class Utils {\r\n \r\n public static void closeStreamQuietly(InputStream inputStream) {\r\n   try {\r\n   if (inputStream != null) {\r\n        inputStream.close();  \r\n    }\r\n  } catch (IOException e) {\r\n   \/\/ ignore exception\r\n  }\r\n }\r\n\r\n}\r\n<\/pre>\n<p>Finally, in order to be able to perform HTTP requests the corresponding permission has to be granted. Thus, add the <a href=\"http:\/\/developer.android.com\/reference\/android\/Manifest.permission.html#INTERNET\">android.permission.INTERNET<\/a> to the project&#8217;s AndroidManifest.xml file which now is as follows:  <\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;manifest xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n      package=\"com.javacodegeeks.android.apps.moviesearchapp\"\r\n      android:versionCode=\"1\"\r\n      android:versionName=\"1.0\"&gt;\r\n    &lt;application android:icon=\"@drawable\/icon\" android:label=\"@string\/app_name\"&gt;\r\n        &lt;activity android:name=\".MovieSearchAppActivity\"\r\n                  android:label=\"@string\/app_name\"&gt;\r\n            &lt;intent-filter&gt;\r\n                &lt;action android:name=\"android.intent.action.MAIN\" \/&gt;\r\n                &lt;category android:name=\"android.intent.category.LAUNCHER\" \/&gt;\r\n            &lt;\/intent-filter&gt;\r\n        &lt;\/activity&gt;\r\n\r\n    &lt;\/application&gt;\r\n    &lt;uses-sdk android:minSdkVersion=\"3\" \/&gt;\r\n &lt;uses-permission android:name=\"android.permission.INTERNET\"&gt;&lt;\/uses-permission&gt;\r\n&lt;\/manifest&gt; \r\n<\/pre>\n<p>So, we have prepared the infrastructure for executing HTTP GET requests. At the following tutorials, we will use that in order to retrieve XML data and images for our application&#8217;s needs. You can download <a href=\"http:\/\/dl.dropbox.com\/u\/7215751\/JavaCodeGeeks\/AndroidFullAppTutorialPart02\/AndroidMovieSearchAppProject_Part02.zip\">here<\/a> the Eclipse project created so far.  <\/p>\n<div style=\"margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/10\/android-full-application-tutorial.html\">\u201cAndroid Full Application Tutorial\u201d series<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/android-text-to-speech-application.html\">Android Text-To-Speech Application<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/android-reverse-geocoding-yahoo-api.html\">Android Reverse Geocoding with Yahoo API &#8211; PlaceFinder<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/android-location-based-services.html\">Android Location Based Services Application \u2013 GPS location<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/embracing-android-awesomeness-quick.html\">Install Android OS on your PC with VirtualBox<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/06\/embracing-android-awesomeness-quick.html\">Embracing the Android awesomeness: A quick overview<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This is the second part of the \u201cAndroid Full Application Tutorial\u201d series. The complete application aims to provide an easy way of performing movies\/actors searching over the internet. In the first part of the series (\u201cMain Activity UI\u201d), we created the Eclipse project and set up a basic interface for the main activity of the &hellip;<\/p>\n","protected":false},"author":3,"featured_media":46,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[83,29],"class_list":["post-317","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-core","tag-android-tutorial","tag-eclipse"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android Full App, Part 2: Using the HTTP API - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This is the second part of the \u201cAndroid Full Application Tutorial\u201d series. The complete application aims to provide an easy way of performing\" \/>\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.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Full App, Part 2: Using the HTTP API - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This is the second part of the \u201cAndroid Full Application Tutorial\u201d series. The complete application aims to provide an easy way of performing\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2010-10-24T14:17:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T19:20:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ilias Tsagklis\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ilias Tsagklis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html\"},\"author\":{\"name\":\"Ilias Tsagklis\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9a83496b285d30c61e8a674625c1350e\"},\"headline\":\"Android Full App, Part 2: Using the HTTP API\",\"datePublished\":\"2010-10-24T14:17:00+00:00\",\"dateModified\":\"2012-10-21T19:20:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html\"},\"wordCount\":979,\"commentCount\":6,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"keywords\":[\"Android Tutorial\",\"Eclipse\"],\"articleSection\":[\"Android Core\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html\",\"name\":\"Android Full App, Part 2: Using the HTTP API - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"datePublished\":\"2010-10-24T14:17:00+00:00\",\"dateModified\":\"2012-10-21T19:20:30+00:00\",\"description\":\"This is the second part of the \u201cAndroid Full Application Tutorial\u201d series. The complete application aims to provide an easy way of performing\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/10\\\/android-full-app-part-2-using-http-api.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Android Core\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\\\/android-core\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Android Full App, Part 2: Using the HTTP API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9a83496b285d30c61e8a674625c1350e\",\"name\":\"Ilias Tsagklis\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g\",\"caption\":\"Ilias Tsagklis\"},\"description\":\"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"http:\\\/\\\/www.iliastsagklis.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/iliastsagklis\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/ilias-tsagklis\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Full App, Part 2: Using the HTTP API - Java Code Geeks","description":"This is the second part of the \u201cAndroid Full Application Tutorial\u201d series. The complete application aims to provide an easy way of performing","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.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html","og_locale":"en_US","og_type":"article","og_title":"Android Full App, Part 2: Using the HTTP API - Java Code Geeks","og_description":"This is the second part of the \u201cAndroid Full Application Tutorial\u201d series. The complete application aims to provide an easy way of performing","og_url":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2010-10-24T14:17:00+00:00","article_modified_time":"2012-10-21T19:20:30+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","type":"image\/jpeg"}],"author":"Ilias Tsagklis","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Ilias Tsagklis","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html"},"author":{"name":"Ilias Tsagklis","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9a83496b285d30c61e8a674625c1350e"},"headline":"Android Full App, Part 2: Using the HTTP API","datePublished":"2010-10-24T14:17:00+00:00","dateModified":"2012-10-21T19:20:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html"},"wordCount":979,"commentCount":6,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","keywords":["Android Tutorial","Eclipse"],"articleSection":["Android Core"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html","url":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html","name":"Android Full App, Part 2: Using the HTTP API - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","datePublished":"2010-10-24T14:17:00+00:00","dateModified":"2012-10-21T19:20:30+00:00","description":"This is the second part of the \u201cAndroid Full Application Tutorial\u201d series. The complete application aims to provide an easy way of performing","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2010\/10\/android-full-app-part-2-using-http-api.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/www.javacodegeeks.com\/category\/android"},{"@type":"ListItem","position":3,"name":"Android Core","item":"https:\/\/www.javacodegeeks.com\/category\/android\/android-core"},{"@type":"ListItem","position":4,"name":"Android Full App, Part 2: Using the HTTP API"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9a83496b285d30c61e8a674625c1350e","name":"Ilias Tsagklis","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/43505f28bb49f6e290c24be0b209ccc1af350f0f6587025ffd4847ef44bf6b78?s=96&d=mm&r=g","caption":"Ilias Tsagklis"},"description":"Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.","sameAs":["http:\/\/www.iliastsagklis.com\/","https:\/\/www.linkedin.com\/in\/iliastsagklis"],"url":"https:\/\/www.javacodegeeks.com\/author\/ilias-tsagklis"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=317"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/317\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}