2012-04-06 72 views
1

我的開發控制檯中有ANR錯誤報告。我需要在我的服務中產生一個工作線程關閉onSignalStrengthsChanged以停止針對長sql查詢的ANR?ANR錯誤 - > ANR keyDispatchingTimedOut

我也不知道這是一個互斥鎖,但我只通過ContentProvider訪問我的分貝。

對於長查詢或互斥鎖ANR,這是ANR嗎?

DALVIK線程:(互斥:TLL = 0 TSL = 0 TSCL = 0 GHL = 0 HWL = 0 hwll = 0) 「主」 PRIO = 5 TID = 1個NATIVE | group =「main」sCount = 1 dsCount = 0 obj = 0x4002a278 self = 0xcf50 | sysTid = 9149漂亮= 0 =附表0/0

at android.database.sqlite.SQLiteStatement.native_execute(Native Method) 
at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61) 
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1582) 
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426) 
at kenyu73.realsignal.DatabaseProvider.insert(DatabaseProvider.java:55) 
at android.content.ContentProvider$Transport.insert(ContentProvider.java:198) 
at android.content.ContentResolver.insert(ContentResolver.java:618) 
at kenyu73.realsignal.DatabaseWrapper.insert(DatabaseWrapper.java:189) 
at kenyu73.realsignal.SignalStats.updateDbStats(SignalStats.java:154) 
at kenyu73.realsignal.SignalStats.updateSignalStats(SignalStats.java:116) 
at kenyu73.realsignal.RealSignalService$2.onSignalStrengthsChanged(RealSignalService.java:156) 
at android.telephony.PhoneStateListener$2.handleMessage(PhoneStateListener.java:329) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:130) 
at android.app.ActivityThread.main(ActivityThread.java:3695) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:507) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
at dalvik.system.NativeStart.main(Native Method) 

回答

1

內容提供商查詢默認是在UI線程中運行,因此建議做一個新的線程來完成查詢工作。

也,mutex lock當試圖獲得已被鎖定的鎖將使用次數,但如果只有一個線程,則鎖可能不是必需的。