From 7335cfd9bb420c570c712ee081bb0927991227dd Mon Sep 17 00:00:00 2001 From: Vairavan Srinivasan Date: Sat, 18 Aug 2012 18:36:03 -0700 Subject: [PATCH] ActivityThread: Avoid creating duplicate handlers and reuse mH sMainThreadHandler is used for notification of changes in SharedPreferences and refers to a new instance of Handler instead of the existing instance, mH, of the ActivityThread. Fix to reuse existing handlers associated with main looper. Change-Id: I794a5802a9eacdb188bd0619db5e70e3ae89a07d --- core/java/android/app/ActivityThread.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 7242029a7c031..b7e0683a9fc61 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -4728,13 +4728,14 @@ public final class ActivityThread { Process.setArgV0(""); Looper.prepareMainLooper(); - if (sMainThreadHandler == null) { - sMainThreadHandler = new Handler(); - } ActivityThread thread = new ActivityThread(); thread.attach(false); + if (sMainThreadHandler == null) { + sMainThreadHandler = thread.getHandler(); + } + AsyncTask.init(); if (false) {