title: AsyncTask interrupted exception in Android?
body: <p>I am facing an issue with AsynsTask in my Application. I really do not understand the reason of it happening.</p>
  
  <p>The issue is "The application works perfectly usually, now when any of the <code>activity</code> is displayed on the screen and I keep my device idle for a longer period of time. Then when I make the keyguard on the view of the last active activity is displayed to me. But as soon as I click on any component below mentioned exception is thrown. If the device is not kept for a longer period of time then there is no problem as such. The application makes http connection in onResume of most of the activities. I did this since every time the user comes to particular view then he should get the updates lists of posts from the webservice"</p>
  
  <pre><code>W/AsyncTask(18829): java.lang.InterruptedException
  W/AsyncTask(18829):     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1254)
  W/AsyncTask(18829):     at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:219)
  W/AsyncTask(18829):     at java.util.concurrent.FutureTask.get(FutureTask.java:82)
  W/AsyncTask(18829):     at android.os.AsyncTask$3.done(AsyncTask.java:196)
  W/AsyncTask(18829):     at java.util.concurrent.FutureTask$Sync.innerCancel(FutureTask.java:293)
  W/AsyncTask(18829):     at java.util.concurrent.FutureTask.cancel(FutureTask.java:75)
  W/AsyncTask(18829):     at android.os.AsyncTask.cancel(AsyncTask.java:325)
  W/AsyncTask(18829):     at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:73)
  W/AsyncTask(18829):     at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:1)
  W/AsyncTask(18829):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
  W/AsyncTask(18829):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  W/AsyncTask(18829):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  W/AsyncTask(18829):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
  W/AsyncTask(18829):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  W/AsyncTask(18829):     at java.lang.Thread.run(Thread.java:1096)
  W/InputManagerService(   85): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44daac80
  D/NetworkStateTracker(   85): setDetailed state, old =CONNECTED and new state=DISCONNECTED
  D/NetworkStateTracker(   85): setDetailed state, old =CONNECTED and new state=OBTAINING_IPADDR
  D/WifiStateTracker(   85): DhcpHandler: DHCP request started
  D/ConnectivityService(   85): ConnectivityChange for WIFI: CONNECTING/OBTAINING_IPADDR
  D/ConnectivityService(   85): Dropping ConnectivityChange for WIFI: CONNECTING/OBTAINING_IPADDR
  I/AudioHardwareQSD(   59): AudioHardware pcm playback is going to standby.
  I/System.out(18829): URL for Subsection Bookmark reply ==&gt; http://www.softwebdemo.com/viral/babbleville/services/getvilledetails.php?action=getbookmarksubsection&amp;Userid=51&amp;start=0&amp;end=30
  W/dalvikvm(18829): threadid=10: thread exiting with uncaught exception (group=0x4001d7f0)
  E/AndroidRuntime(18829): FATAL EXCEPTION: AsyncTask #3
  E/AndroidRuntime(18829): java.lang.RuntimeException: An error occured while executing doInBackground()
  E/AndroidRuntime(18829):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
  E/AndroidRuntime(18829):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
  E/AndroidRuntime(18829):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
  E/AndroidRuntime(18829):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
  E/AndroidRuntime(18829):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
  E/AndroidRuntime(18829):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
  E/AndroidRuntime(18829):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
  E/AndroidRuntime(18829):    at java.lang.Thread.run(Thread.java:1096)
  E/AndroidRuntime(18829): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
  E/AndroidRuntime(18829):    at android.os.Handler.&lt;init&gt;(Handler.java:121)
  E/AndroidRuntime(18829):    at android.app.Dialog.&lt;init&gt;(Dialog.java:101)
  E/AndroidRuntime(18829):    at android.app.AlertDialog.&lt;init&gt;(AlertDialog.java:63)
  E/AndroidRuntime(18829):    at android.app.AlertDialog.&lt;init&gt;(AlertDialog.java:59)
  E/AndroidRuntime(18829):    at android.app.AlertDialog$Builder.create(AlertDialog.java:786)
  E/AndroidRuntime(18829):    at com.babbleville.utils.BabbleVilleSyncTask.AlertOnInternetConnetion(BabbleVilleSyncTask.java:188)
  E/AndroidRuntime(18829):    at com.babbleville.utils.BabbleVilleSyncTask.checkInternetConnetion(BabbleVilleSyncTask.java:169)
  E/AndroidRuntime(18829):    at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:57)
  E/AndroidRuntime(18829):    at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:1)
  E/AndroidRuntime(18829):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
  E/AndroidRuntime(18829):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
  E/AndroidRuntime(18829):    ... 4 more
  W/ActivityManager(   85):   Force finishing activity com.babbleville/.VilleBookmarkReply
  E/WindowManager(18829): Activity com.babbleville.VilleBookmarkReply has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44a25940 that was originally added here
  E/WindowManager(18829): android.view.WindowLeaked: Activity com.babbleville.VilleBookmarkReply has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44a25940 that was originally added here
  E/WindowManager(18829):     at android.view.ViewRoot.&lt;init&gt;(ViewRoot.java:247)
  E/WindowManager(18829):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
  E/WindowManager(18829):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
  E/WindowManager(18829):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
  E/WindowManager(18829):     at android.app.Dialog.show(Dialog.java:241)
  E/WindowManager(18829):     at com.babbleville.utils.BabbleVilleSyncTask.onPreExecute(BabbleVilleSyncTask.java:48)
  E/WindowManager(18829):     at android.os.AsyncTask.execute(AsyncTask.java:391)
  E/WindowManager(18829):     at com.babbleville.VilleBookmarkReply.loadSubsectionBookmark(VilleBookmarkReply.java:1186)
  E/WindowManager(18829):     at com.babbleville.VilleBookmarkReply.loadBookmarkSubsection(VilleBookmarkReply.java:1171)
  E/WindowManager(18829):     at com.babbleville.VilleBookmarkReply.onClick(VilleBookmarkReply.java:277)
  E/WindowManager(18829):     at android.view.View.performClick(View.java:2408)
  E/WindowManager(18829):     at android.view.View$PerformClick.run(View.java:8816)
  E/WindowManager(18829):     at android.os.Handler.handleCallback(Handler.java:587)
  E/WindowManager(18829):     at android.os.Handler.dispatchMessage(Handler.java:92)
  E/WindowManager(18829):     at android.os.Looper.loop(Looper.java:123)
  E/WindowManager(18829):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  E/WindowManager(18829):     at java.lang.reflect.Method.invokeNative(Native Method)
  E/WindowManager(18829):     at java.lang.reflect.Method.invoke(Method.java:521)
  E/WindowManager(18829):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  E/WindowManager(18829):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  E/WindowManager(18829):     at dalvik.system.NativeStart.main(Native Method)
  D/NetworkStateTracker(   85): setDetailed state, old =OBTAINING_IPADDR and new state=CONNECTED
  D/ConnectivityService(   85): ConnectivityChange for WIFI: CONNECTED/CONNECTED
  D/WifiWatchdogService(   85): (android.server.ServerThread) Softwebsolutions (00:25:9c:0c:2d:c0) does not require the watchdog
  D/ConnectivityService(   85): adding dns 192.168.3.105 for WIFI
  D/Tethering(   85): Tethering got CONNECTIVITY_ACTION
  D/Tethering(   85): MasterInitialState.processMessage what=3
  E/HierarchicalStateMachine(   85): TetherMaster - unhandledMessage: msg.what=3
  I/GTalkService(  214): [ServiceAutoStarter] --- connectivity changed
  </code></pre>
  
  <p>Can someone let me know the reason behind this error and any solution to this?</p>