title: ANR due to deadlock between app and widget?
body: <p>I have an android app that a) performs an updateData() function (querying content providers and HTTP requests from internet among other things) in a thread, and b) has a home screen widget that performs the same updateData() function every 30mins (not in a thread).</p>
  
  <p>a) looks like this:</p>
  
  <pre><code>public class MoodMain extends Activity{
      public void onCreate(...)
      {
          Thread t = new Thread()
          {
              public void run()
              {
                       updateData(this);
              }
          };
          t.start();
      }
  </code></pre>
  
  <p>b) looks like this :</p>
  
  <pre><code>public class MoodAppWidgetProvider extends AppWidgetProvider { 
      public void onUpdate(Context context, ...)
      { 
          updateData(context);
      } }
  </code></pre>
  
  <p>Now people are reporting ANRs where threads are stopped at same place in updateData(context), one thread for a) and one for b).  Stack traces look like the following:</p>
  
  <p>1st example:  </p>
  
  <blockquote>
    <p>"main" prio=5 tid=1 NATIVE   | group="main" sCount=1 dsCount=0 s=N
    obj=0x40025ad8 self=0xcd80   | sysTid=23053 nice=0 sched=0/0
    cgrp=default handle=-1345017808   | schedstat=( 5672943129 29267974835
    13299 )   at android.os.BinderProxy.transact(Native Method)   at
    android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:370)
    at
    android.content.ContentProviderProxy.query(ContentProviderNative.java:408)
    ...</p>
    
    <p>"Thread-10" prio=5 tid=9 NATIVE   | group="main" sCount=1 dsCount=0
    s=N obj=0x4629ba88 self=0x2d1750   | sysTid=23062 nice=0 sched=0/0
    cgrp=default handle=2955408   | schedstat=( 53100602 8822875969 600 ) 
    at android.os.BinderProxy.transact(Native Method)   at
    android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:370)
    at
    android.content.ContentProviderProxy.query(ContentProviderNative.java:408)
    at android.content.ContentResolver.query(ContentResolver.java:245) ...</p>
  </blockquote>
  
  <p>2nd example:</p>
  
  <blockquote>
    <p>"main" prio=5 tid=1 NATIVE   | group="main" sCount=1 dsCount=0 s=N
    obj=0x40020a30 self=0xcd88   | sysTid=19319 nice=0 sched=0/0
    cgrp=default handle=-1345026000   at
    java.net.InetAddress.getaddrinfo(Native Method)   at
    java.net.InetAddress.lookupHostByName(InetAddress.java:508)   at
    java.net.InetAddress.getAllByNameImpl(InetAddress.java:280)   at
    java.net.InetAddress.getByName(InetAddress.java:310)   at
    java.net.InetSocketAddress.(InetSocketAddress.java:110) ...</p>
    
    <p>"Thread-10" prio=5 tid=9 NATIVE   | group="main" sCount=1 dsCount=0
    s=N obj=0x458842e8 self=0x245cc0   | sysTid=20153 nice=0 sched=0/0
    cgrp=default handle=2388904   at
    java.net.InetAddress.getaddrinfo(Native Method)   at
    java.net.InetAddress.lookupHostByName(InetAddress.java:508) ...</p>
    
    <p>"Thread-8" prio=5 tid=7 NATIVE   | group="main" sCount=1 dsCount=0 s=N
    obj=0x45867030 self=0x22c528   | sysTid=20151 nice=0 sched=0/0
    cgrp=default handle=2277944   at
    java.net.InetAddress.getaddrinfo(Native Method)   at
    java.net.InetAddress.lookupHostByName(InetAddress.java:508) ...   at
    com.admob.android.ads.i.d(AdMobURLConnector.java:153)   at
    com.admob.android.ads.b.a(AdRequester.java:206)   at
    com.admob.android.ads.AdView$b.run(AdView.java:655)</p>
  </blockquote>
  
  <p>Looks like some kind of task deadlock.  Any ideas how to solve this anyone please?</p>