Skip to content

Commit 7335cfd

Browse files
committed
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
1 parent 9885362 commit 7335cfd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4728,13 +4728,14 @@ public static void main(String[] args) {
47284728
Process.setArgV0("<pre-initialized>");
47294729

47304730
Looper.prepareMainLooper();
4731-
if (sMainThreadHandler == null) {
4732-
sMainThreadHandler = new Handler();
4733-
}
47344731

47354732
ActivityThread thread = new ActivityThread();
47364733
thread.attach(false);
47374734

4735+
if (sMainThreadHandler == null) {
4736+
sMainThreadHandler = thread.getHandler();
4737+
}
4738+
47384739
AsyncTask.init();
47394740

47404741
if (false) {

0 commit comments

Comments
 (0)