{"id":3598,"date":"2013-05-11T17:38:40","date_gmt":"2013-05-11T14:38:40","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=3598"},"modified":"2013-05-11T17:39:58","modified_gmt":"2013-05-11T14:39:58","slug":"android-asynctask-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/","title":{"rendered":"Android Asynctask Example"},"content":{"rendered":"<p>In this tutorial we are going to see how to use Android <code><a href=\"http:\/\/developer.android.com\/reference\/android\/os\/AsyncTask.html\">AsyncTask<\/a><\/code>. As we read from the Android Documentation :<\/p>\n<ul>\n<li>AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and\/or handlers.<\/li>\n<li>AsyncTask is designed to be a helper class around\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/lang\/Thread.html\">Thread<\/a><\/code>\u00a0and\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/android\/os\/Handler.html\">Handler<\/a><\/code>\u00a0and does not constitute a generic threading framework. AsyncTasks should ideally be used for short operations (a few seconds at the most.) If you need to keep threads running for long periods of time, it is highly recommended you use the various APIs provided by the\u00a0<code>java.util.concurrent<\/code>\u00a0pacakge such as\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/util\/concurrent\/Executor.html\">Executor<\/a><\/code>,\u00a0<code><a href=\"http:\/\/developer.android.com\/reference\/java\/util\/concurrent\/ThreadPoolExecutor.html\">ThreadPoolExecutor<\/a><\/code>\u00a0and<code><a href=\"http:\/\/developer.android.com\/reference\/java\/util\/concurrent\/FutureTask.html\">FutureTask<\/a><\/code>.<\/li>\n<li>An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. An asynchronous task is defined by 3 generic types, called\u00a0<code>Params<\/code>,\u00a0<code>Progress<\/code>\u00a0and<code>Result<\/code>, and 4 steps, called\u00a0<code>onPreExecute<\/code>,\u00a0<code>doInBackground<\/code>,\u00a0<code>onProgressUpdate<\/code>\u00a0and\u00a0<code>onPostExecute.<\/code><\/li>\n<\/ul>\n<p>In this example we are going to load a web page in the backgroud and display it in a <code><a href=\"http:\/\/developer.android.com\/reference\/android\/webkit\/WebView.html\">WebView<\/a><\/code>. We will notice that the UI thread still remains fast and responsive in other UI activities.<\/p>\n<p>For this tutorial, we will use the following tools in a Windows 64-bit platform:<\/p>\n<ul>\n<li>JDK 1.7<\/li>\n<li>Eclipse 4.2 Juno<\/li>\n<li>Android SKD 4.2<\/li>\n<\/ul>\n<h3>1. Create a new Android Project<\/h3>\n<p>Open Eclipse IDE and go to File -&gt; New -&gt; Project -&gt; Android -&gt; Android Application Project.\u00a0You have to specify the Application Name, the Project Name and the Package name in the appropriate text fields and then click Next.<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-project-attr.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3599\" alt=\"create-project-attr\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-project-attr.jpg\" width=\"532\" height=\"434\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-project-attr.jpg 532w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-project-attr-300x244.jpg 300w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/a><\/p>\n<p>In the next window make sure the \u201cCreate activity\u201d option is selected in order to create a new activity for your project, and click Next. This is optional as you can create a new activity after creating the project, but you can do it all in one step.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-activity.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3600\" alt=\"check-create-activity\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-activity.jpg\" width=\"532\" height=\"434\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-activity.jpg 532w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/check-create-activity-300x244.jpg 300w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/a><\/p>\n<p>Select \u201cBlankActivity\u201d and click Next.<\/p>\n<p><a href=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-blanc-activity.jpg\"><img decoding=\"async\" alt=\"create-blanc-activity\" src=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/create-blanc-activity.jpg\" width=\"528\" height=\"502\" \/><\/a><\/p>\n<p>You will be asked to specify some information about the new activity. \u00a0In the Layout Name text field you have to specify the name of the file that will contain the layout description of your app. In our case the file\u00a0<code>res\/layout\/main.xml<\/code>\u00a0will be created. Then, click Finish.<\/p>\n<p><a href=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity-attr.jpg\"><img decoding=\"async\" alt=\"new-activity-attr\" src=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/new-activity-attr.jpg\" width=\"484\" height=\"455\" \/><\/a><\/p>\n<h3>2. Create the main layout of the Application<\/h3>\n<p>Open\u00a0<code>res\/layout\/main.xml<\/code>\u00a0file :<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml2.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3601\" alt=\"main-xml\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml2.jpg\" width=\"374\" height=\"445\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml2.jpg 374w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-xml2-252x300.jpg 252w\" sizes=\"(max-width: 374px) 100vw, 374px\" \/><\/a><\/p>\n<p>And paste the following code :<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;LinearLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    android:orientation=\"vertical\" &gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/btn\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:onClick=\"readWebpage\"\r\n        android:text=\"Load Webpage\" &gt;\r\n    &lt;\/Button&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/button1\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:onClick=\"dummyFunc\"\r\n        android:text=\"Dummy Button\" \/&gt;\r\n\r\n    &lt;WebView\r\n        android:id=\"@+id\/webView\"\r\n        android:layout_width=\"fill_parent\"\r\n        android:layout_height=\"fill_parent\" \/&gt;\r\n\r\n&lt;\/LinearLayout&gt;<\/pre>\n<p>Now you may open the Graphical layout editor to preview the User Interface you created:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout-editor.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3602\" alt=\"graphical-layout-editor\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout-editor.jpg\" width=\"569\" height=\"641\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout-editor.jpg 569w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/graphical-layout-editor-266x300.jpg 266w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/a><\/p>\n<h3>3. Code<\/h3>\n<p>Now we have to write the code of the application. Use the Package Explorer to navigate to the Java file of the Activity you\u2019ve created:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3603\" alt=\"main-src\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src.jpg\" width=\"449\" height=\"280\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src.jpg 449w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-src-300x187.jpg 300w\" sizes=\"(max-width: 449px) 100vw, 449px\" \/><\/a><\/p>\n<p>The code of this tutorial is pretty much self\u00a0explanatory.<\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.android.androidasynctasktutorial;\r\n\r\nimport android.app.Activity;\r\nimport android.content.Context;\r\nimport android.os.AsyncTask;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\nimport android.webkit.WebView;\r\nimport android.widget.Toast;\r\n\r\npublic class MainActivity extends Activity {\r\n\tfinal Context context = this;\r\n\r\n\t\/** Called when the activity is first created. *\/\r\n\r\n\t@Override\r\n\tpublic void onCreate(Bundle savedInstanceState) {\r\n\r\n\t\tsuper.onCreate(savedInstanceState);\r\n\t\tsetContentView(R.layout.main);\r\n\r\n\t}\r\n\r\n\tprivate class LoadWebPageASYNC extends AsyncTask&lt;String, Void, String&gt; {\r\n\r\n\t\t@Override\r\n\t\tprotected String doInBackground(String... urls) {\r\n\r\n\t\t\tWebView webView = (WebView) findViewById(R.id.webView);\r\n\t\t\twebView.getSettings().setJavaScriptEnabled(true);\r\n\t\t\twebView.loadUrl(urls[0]);\r\n\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\t@Override\r\n\t\tprotected void onPostExecute(String result) {\r\n\r\n\t\t}\r\n\t}\r\n\r\n\tpublic void dummyFunc(View view){\r\n\t\tToast.makeText(MainActivity.this, \"Button Clicked\", Toast.LENGTH_SHORT).show();\r\n\r\n\t}\r\n\r\n\tpublic void readWebpage(View view) {\r\n\t\tLoadWebPageASYNC task = new LoadWebPageASYNC();\r\n\t\ttask.execute(new String[] { \"http:\/\/www.javacodegeeks.com\" });\r\n\r\n\t}\r\n}<\/pre>\n<h3>4. Run the application<\/h3>\n<p>This is the main screen of our Application:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen3.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3604\" alt=\"main-screen\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen3.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen3.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/main-screen3-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>Now, when you press the \u201cLoad Webpage\u201d button, the\u00a0<a href=\"http:\/\/developer.android.com\/reference\/android\/os\/AsyncTask.html\">AsyncTask<\/a>\u00a0will start downloading and loading the Web Page. But, meanwhile if whe press the &#8220;Dummy Button&#8221;, you will see that the UI remains responsive. As you can see the web pages is loading and the UI is fast and responsive:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/responsive.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3605\" alt=\"responsive\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/responsive.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/responsive.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/responsive-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<p>After a little while:<\/p>\n<p><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/page-loaded.jpg\"><img decoding=\"async\" class=\"alignnone size-full wp-image-3606\" alt=\"page-loaded\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/page-loaded.jpg\" width=\"256\" height=\"470\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/page-loaded.jpg 256w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/page-loaded-163x300.jpg 163w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/p>\n<h3>Download Eclipse Project<\/h3>\n<p>This was an Android Timer Example. Download the Eclipse Project of this tutorial:\u00a0<a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/AndroidAsyncTaskTutorial.zip\">AndroidAsyncTaskTutorial.zip<\/a><a href=\"http:\/\/cdn.javacodegeeks.com\/wp-content\/uploads\/2013\/05\/AndroidTimerExample.zip\"><br \/>\n<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we are going to see how to use Android AsyncTask. As we read from the Android Documentation : AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and\/or handlers. AsyncTask is designed &hellip;<\/p>\n","protected":false},"author":4,"featured_media":1202,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[438],"tags":[1111],"class_list":["post-3598","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asynctask","tag-webview"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android Asynctask Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this tutorial we are going to see how to use Android AsyncTask. As we read from the Android Documentation : AsyncTask enables proper and easy use of\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Asynctask Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this tutorial we are going to see how to use Android AsyncTask. As we read from the Android Documentation : AsyncTask enables proper and easy use of\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-05-11T14:38:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-05-11T14:39:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/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=\"Nikos Maravitsas\" \/>\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=\"Nikos Maravitsas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\"},\"author\":{\"name\":\"Nikos Maravitsas\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b\"},\"headline\":\"Android Asynctask Example\",\"datePublished\":\"2013-05-11T14:38:40+00:00\",\"dateModified\":\"2013-05-11T14:39:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\"},\"wordCount\":503,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"keywords\":[\"WebView\"],\"articleSection\":[\"AsyncTask\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\",\"name\":\"Android Asynctask Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"datePublished\":\"2013-05-11T14:38:40+00:00\",\"dateModified\":\"2013-05-11T14:39:58+00:00\",\"description\":\"In this tutorial we are going to see how to use Android AsyncTask. As we read from the Android Documentation : AsyncTask enables proper and easy use of\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"core\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"os\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/os\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"AsyncTask\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/os\/asynctask\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Android Asynctask Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b\",\"name\":\"Nikos Maravitsas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg\",\"caption\":\"Nikos Maravitsas\"},\"description\":\"Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens. During his studies he discovered his interests about software development and he has successfully completed numerous assignments in a variety of fields. Currently, his main interests are system\u2019s security, parallel systems, artificial intelligence, operating systems, system programming, telecommunications, web applications, human \u2013 machine interaction and mobile development.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/nikos-maravitsas\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Asynctask Example - Java Code Geeks","description":"In this tutorial we are going to see how to use Android AsyncTask. As we read from the Android Documentation : AsyncTask enables proper and easy use of","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:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/","og_locale":"en_US","og_type":"article","og_title":"Android Asynctask Example - Java Code Geeks","og_description":"In this tutorial we are going to see how to use Android AsyncTask. As we read from the Android Documentation : AsyncTask enables proper and easy use of","og_url":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-05-11T14:38:40+00:00","article_modified_time":"2013-05-11T14:39:58+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","type":"image\/jpeg"}],"author":"Nikos Maravitsas","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Nikos Maravitsas","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/"},"author":{"name":"Nikos Maravitsas","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b"},"headline":"Android Asynctask Example","datePublished":"2013-05-11T14:38:40+00:00","dateModified":"2013-05-11T14:39:58+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/"},"wordCount":503,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","keywords":["WebView"],"articleSection":["AsyncTask"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/","url":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/","name":"Android Asynctask Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","datePublished":"2013-05-11T14:38:40+00:00","dateModified":"2013-05-11T14:39:58+00:00","description":"In this tutorial we are going to see how to use Android AsyncTask. As we read from the Android Documentation : AsyncTask enables proper and easy use of","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/android\/core\/os\/asynctask\/android-asynctask-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/"},{"@type":"ListItem","position":3,"name":"core","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/"},{"@type":"ListItem","position":4,"name":"os","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/os\/"},{"@type":"ListItem","position":5,"name":"AsyncTask","item":"https:\/\/examples.javacodegeeks.com\/category\/android\/core\/os\/asynctask\/"},{"@type":"ListItem","position":6,"name":"Android Asynctask Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/686a494fbb577a8d1231862b139cda6b","name":"Nikos Maravitsas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Nikos-Maravitsas-80x96.jpg","caption":"Nikos Maravitsas"},"description":"Nikos has graduated from the Department of Informatics and Telecommunications of The National and Kapodistrian University of Athens. During his studies he discovered his interests about software development and he has successfully completed numerous assignments in a variety of fields. Currently, his main interests are system\u2019s security, parallel systems, artificial intelligence, operating systems, system programming, telecommunications, web applications, human \u2013 machine interaction and mobile development.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/nikos-maravitsas\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/3598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=3598"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/3598\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1202"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=3598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=3598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=3598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}