1:KeyDispatchTimeout(5 seconds) --主要類型
專注于為中小企業(yè)提供網(wǎng)站設(shè)計(jì)、網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)梅州免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000+企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
按鍵或觸摸事件在特定時(shí)間內(nèi)無響應(yīng)
2:BroadcastTimeout(10 seconds)
BroadcastReceiver在特定時(shí)間內(nèi)無法處理完成
3:ServiceTimeout(20 seconds) --小概率類型
Service在特定的時(shí)間內(nèi)無法處理完成
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)
出現(xiàn)ANR問題的原因就是上面紅色代碼中
at com.rayray.cool.activity.WoDeJianYiActivity$1.onClick(WoDeJianYiActivity.java:173) 是Android中Activity
at com.rayray.cool.util.URLUtil.invokeURL(URLUtil.java:136) 是一次耗時(shí)的聯(lián)網(wǎng)請(qǐng)求
Activity中的按鍵事件在特定事件內(nèi)未響應(yīng)造成。
(1)耗時(shí)的操作放入單獨(dú)的線程中處理,如(聯(lián)網(wǎng)、數(shù)據(jù)庫、IO)
(2)盡量避免和UI線程的操作