針對Android Anr問題 畫了一個思維導圖,對其成因、如何定位、解決方式,及使用到的工具做了一個梳理。拋磚引玉,如有不當或不完善之處,請留言批評指教。謝謝!

image.png
更多《圖解系列文章》的素材包括思維導圖源文件請到圖解技術(shù)素材庫 Github倉庫下載
StrictMode 初始化代碼
@Override
public void onCreate() {
super.onCreate();
// 分別為MainThread和VM設(shè)置Strict Mode
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.detectResourceMismatches()
.detectCustomSlowCalls()
.penaltyDeath()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.detectLeakedRegistrationObjects()
.detectActivityLeaks()
.penaltyDeath()
.build());
}
}