重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
1:KeyDispatchTimeout(5 seconds) --主要类型
专注于为中小企业提供网站设计、网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业梅州免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
按键或触摸事件在特定时间内无响应
2:BroadcastTimeout(10 seconds)
BroadcastReceiver在特定时间内无法处理完成
3:ServiceTimeout(20 seconds) --小概率类型
Service在特定的时间内无法处理完成
DALVIK THREADS: (mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0) "main" prio=5 tid=1 NATIVE | group="main" sCount=1 dsCount=0 obj=0x40025340 self=0xd180 | sysTid=1071 nice=0 sched=0/0 cgrp=default handle=-1344994080 | schedstat=( 2355584448 1199910712 3410 ) at java.net.InetAddress.getaddrinfo(Native Method) at java.net.InetAddress.lookupHostByName(InetAddress.java:540) at java.net.InetAddress.getAllByNameImpl(InetAddress.java:333) at java.net.InetAddress.getAllByName(InetAddress.java:295) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:100) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection. (HttpConnection.java:79) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:353) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:120) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:316) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:298) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:236) at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:645) at com.rayray.cool.util.URLUtil.invokeURL(URLUtil.java:136) at com.rayray.cool.activity.WoDeJianYiActivity$1.onClick(WoDeJianYiActivity.java:173) at android.view.View.performClick(View.java:2535) at android.view.View$PerformClick.run(View.java:9129) at android.os.Handler.handleCallback(Handler.java:618) at android.os.Handler.dispatchMessage(Handler.java:123) at android.os.Looper.loop(SourceFile:351) at android.app.ActivityThread.main(ActivityThread.java:3821) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:538) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:727) at dalvik.system.NativeStart.main(Native Method)
出现ANR问题的原因就是上面红色代码中
at com.rayray.cool.activity.WoDeJianYiActivity$1.onClick(WoDeJianYiActivity.java:173) 是Android中Activity
at com.rayray.cool.util.URLUtil.invokeURL(URLUtil.java:136) 是一次耗时的联网请求
Activity中的按键事件在特定事件内未响应造成。
(1)耗时的操作放入单独的线程中处理,如(联网、数据库、IO)
(2)尽量避免和UI线程的操作