Code example for Handler

0
        } 
    } 
 
    UpdateLockService(Context context) {
        mContext = context;
        mLocks = new LockWatcher(new Handler(), "UpdateLocks");
 
        // Consider just-booting to be a reasonable time to allow 
        // interruptions for update installation etc. 
        sendLockChangedBroadcast(true); 
    } 
 
    void sendLockChangedBroadcast(boolean state) {
        // Safe early during boot because this broadcast only goes to registered receivers. 
        long oldIdent = Binder.clearCallingIdentity();
        try { 
            Intent intent = new Intent(UpdateLock.UPDATE_LOCK_CHANGED)
                    .putExtra(UpdateLock.NOW_IS_CONVENIENT, state)
                    .putExtra(UpdateLock.TIMESTAMP, System.currentTimeMillis())
                    .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); 
            mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);