OSDN Git Service

Asynchronously handle TIME_TICK to not block the broadcast.
authorPatrick Scott <phanna@android.com>
Thu, 19 Nov 2009 21:06:27 +0000 (16:06 -0500)
committerPatrick Scott <phanna@android.com>
Thu, 19 Nov 2009 21:06:27 +0000 (16:06 -0500)
BUG: 2268458

src/com/android/deskclock/DigitalClock.java

index 38ed91b..69a7156 100644 (file)
@@ -58,7 +58,12 @@ public class DigitalClock extends LinearLayout {
                             Intent.ACTION_TIMEZONE_CHANGED)) {
                     mCalendar = Calendar.getInstance();
                 }
-                updateTime();
+                // Post a runnable to avoid blocking the broadcast.
+                mHandler.post(new Runnable() {
+                        public void run() {
+                            updateTime();
+                        }
+                });
             }
         };
 
@@ -131,7 +136,7 @@ public class DigitalClock extends LinearLayout {
             filter.addAction(Intent.ACTION_TIME_TICK);
             filter.addAction(Intent.ACTION_TIME_CHANGED);
             filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
-            mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
+            mContext.registerReceiver(mIntentReceiver, filter);
         }
 
         /* monitor 12/24-hour display preference */