ANR是由于应用程序和小部件之间的死锁吗?
我有一个android应用程序a)在一个线程中执行updateData()函数(查询来自互联网的内容提供程序和HTTP请求),以及b)每隔30分钟执行一次updateData()函数的主屏幕小部件不在一个线程中)。
a)看起来像这样:
public class MoodMain extends Activity{
public void onCreate(...)
{
Thread t = new Thread()
{
public void run()
{
updateData(this);
}
};
t.start();
}
b)看起来像这样:
public class MoodAppWidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, ...)
{
updateData(context);
} }
现在,人们报告ANR在线程在updateData(上下文)中的相同位置停止,一个线程用于a),另一个用于b)。 堆栈跟踪如下所示:
第一个例子:
“主”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 =默认句柄= -1345017808 | 在android.content.ContentProviderProxy.query(ContentProviderNative.java:408)android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:370)android.os.BinderProxy.transact(本地方法)schedstat =(5672943129 29267974835 13299)。 ..
“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 =默认句柄= 2955408 | 在android.content.ContentProviderProxy.bulkQueryInternal(ContentProviderNative.java:370)android.content.ContentProviderProxy.query(ContentProviderNative.java:408)at android.os.BinderProxy.transact(Native Method)处schedstat =(53100602 8822875969 600) android.content.ContentResolver.query(ContentResolver.java:245)...
第二个例子:
“主”prio = 5 tid = 1 NATIVE | group =“main”sCount = 1 dsCount = 0 s = N obj = 0x40020a30 self = 0xcd88 | 在java.net上的java.net.InetAddress.lookupHostByName(InetAddress.java:508)处的java.net.InetAddress.getaddrinfo(Native Method)处,sysTid = 19319 nice = 0 sched = 0/0 cgrp = default handle = -1345026000。 InetAddress.getAllByNameImpl(InetAddress.java:280)at java.net.InetAddress.getByName(InetAddress.java:310)at java.net.InetSocketAddress。(InetSocketAddress.java:110)...
“Thread-10”prio = 5 tid = 9 NATIVE | group =“main”sCount = 1 dsCount = 0 s = N obj = 0x458842e8 self = 0x245cc0 | 在java.net.InetAddress.getaddrinfo(本地方法)在java.net.InetAddress.lookupHostByName(InetAddress.java:508)... sysTid = 20153 nice = 0 sched = 0/0 cgrp =默认句柄= 2388904 ...
“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。 adm.android.ads.id(AdMobURLConnector.java:153)at com.admob.android.ads.ba(AdRequester.java:206)at com.admob.android.ads.AdView $ b.run(AdView.java: 655)
看起来像某种任务僵局。 任何想法如何解决这个人请吗?
我相信这个问题是我在widgetProvider的onUpdate()函数中做了一个很长的过程。 我修改了我的代码以生成一个线程来执行密集的功能,到目前为止,没有更多的用户报告冻结。
链接地址: http://www.djcxy.com/p/61975.html上一篇: ANR due to deadlock between app and widget?
下一篇: Need some insight on this recurring issue, ANR keyDispatchingTimedOut