{"id":1221,"date":"2016-02-11T11:15:54","date_gmt":"2016-02-11T03:15:54","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1221"},"modified":"2026-08-18T12:58:48","modified_gmt":"2026-08-18T04:58:48","slug":"localbroadcastmanager-%e7%9a%84%e5%ae%9e%e7%8e%b0%e5%8e%9f%e7%90%86%ef%bc%8c%e8%bf%98%e6%98%af-binder%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=1221","title":{"rendered":"LocalBroadcastManager \u7684\u5b9e\u73b0\u539f\u7406\uff0c\u8fd8\u662f Binder\uff1f"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">LocalBroadcastManager<\/code> \u53ea\u80fd\u505a\u5e94\u7528\u5185\u901a\u4fe1\uff0c\u6bd4\u7cfb\u7edf <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">BroadcastReceiver<\/code> \u66f4\u5b89\u5168\u3001\u6548\u7387\u66f4\u9ad8\uff0c\u4e5f\u662f\u5b98\u65b9\u63a8\u8350\u7684\u5e94\u7528\u5185\u5e7f\u64ad\u3002\u7cfb\u7edf\u5e7f\u64ad\u8d70 Binder\uff1b\u540d\u5b57\u91cc\u7684 Local \u5bb9\u6613\u8ba9\u4eba\u4ee5\u4e3a\u5b83\u5e95\u5c42\u4e5f\u662f Binder\u3002\u70b9\u8fdb\u6e90\u7801\u4f1a\u53d1\u73b0\uff1a\u66f4\u5b89\u5168\u9ad8\u6548\u7684\u5b9e\u73b0\u5176\u5b9e\u5f88\u773c\u719f\u2014\u2014Handler\u3002<\/p>\n<\/blockquote>\n<p><!--more--><\/p>\n<p style=\"margin: 1em 0px;\">\u7528\u6cd5\u548c\u666e\u901a BroadcastReceiver \u5dee\u4e0d\u591a\u3002\u66f4\u591a\u53ef\u89c1 BroadcastReceiver \u8be6\u7ec6\u4ecb\u7ecd\u3002<\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e00\u3001\u600e\u4e48\u7528<\/span><\/h2>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">1. \u81ea\u5b9a\u4e49 BroadcastReceiver \u5b50\u7c7b<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public class LocalBroadcastReceiver extends BroadcastReceiver {\n\n    @Override\n    public void onReceive(Context context, Intent intent) {\n        localMsg.setText(intent.getStringExtra(MSG_KEY));\n    }\n}<\/code><\/pre>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">2. \u6ce8\u518c\u63a5\u6536\u5668<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">LocalBroadcastReceiver localReceiver = new LocalBroadcastReceiver();\nLocalBroadcastManager.getInstance(context).registerReceiver(localReceiver, new IntentFilter(ACTION_LOCAL_SEND));<\/code><\/pre>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">3. \u53d1\u9001\u5e7f\u64ad<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ACTION_LOCAL_SEND));<\/code><\/pre>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">4. \u53d6\u6d88\u6ce8\u518c<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">LocalBroadcastManager.getInstance(context).unregisterReceiver(localReceiver);<\/code><\/pre>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e8c\u3001\u6784\u9020\u51fd\u6570\uff1a\u5355\u4f8b + \u4e3b\u7ebf\u7a0b Handler<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u6e90\u7801\u89c1 LocalBroadcastManager.java\u3002\u5355\u4f8b\uff0c\u6784\u9020\u51fd\u6570\u79c1\u6709\u3002\u57fa\u4e8e\u4e3b\u7ebf\u7a0b Looper \u5efa Handler\uff0chandleMessage \u91cc\u5904\u7406\u5e7f\u64ad\uff0c\u6838\u5fc3\u662f\u540e\u9762\u7684 executePendingBroadcasts()\u3002\u53cc\u68c0\u9501\u5199\u6cd5\u53ef\u518d\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public static LocalBroadcastManager getInstance(Context context) {\n    synchronized (mLock) {\n        if (mInstance == null) {\n            mInstance = new LocalBroadcastManager(context.getApplicationContext());\n        }\n        return mInstance;\n    }\n}\n\nprivate LocalBroadcastManager(Context context) {\n    mAppContext = context;\n    mHandler = new Handler(context.getMainLooper()) {\n        @Override\n        public void handleMessage(Message msg) {\n            switch (msg.what) {\n                case MSG_EXEC_PENDING_BROADCASTS:\n                    executePendingBroadcasts();\n                    break;\n                default:\n                    super.handleMessage(msg);\n            }\n        }\n    };\n}<\/code><\/pre>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e09\u3001\u6ce8\u518c\uff1a\u4e24\u5f20\u8868<\/span><\/h2>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">HashMap&lt;BroadcastReceiver, ArrayList&lt;IntentFilter&gt;&gt; mReceivers\n            = new HashMap&lt;BroadcastReceiver, ArrayList&lt;IntentFilter&gt;&gt;();\nHashMap&lt;String, ArrayList&lt;ReceiverRecord&gt;&gt; mActions\n            = new HashMap&lt;String, ArrayList&lt;ReceiverRecord&gt;&gt;();\n\npublic void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {\n    synchronized (mReceivers) {\n        ReceiverRecord entry = new ReceiverRecord(filter, receiver);\n        ArrayList&lt;IntentFilter&gt; filters = mReceivers.get(receiver);\n        if (filters == null) {\n            filters = new ArrayList&lt;IntentFilter&gt;(1);\n            mReceivers.put(receiver, filters);\n        }\n        filters.add(filter);\n        for (int i=0; i&lt;filter.countActions(); i++) {\n            String action = filter.getAction(i);\n            ArrayList&lt;ReceiverRecord&gt; entries = mActions.get(action);\n            if (entries == null) {\n                entries = new ArrayList&lt;ReceiverRecord&gt;(1);\n                mActions.put(action, entries);\n            }\n            entries.add(entry);\n        }\n    }\n}<\/code><\/pre>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">mReceivers<\/code>\uff1a\u4ee5 BroadcastReceiver \u4e3a key\u3001IntentFilter \u94fe\u8868\u4e3a value\u3002\u65b9\u4fbf unregisterReceiver\uff0c\u540c\u65f6\u5f53\u5bf9\u8c61\u9501\uff0c\u9650\u5236\u6ce8\u518c\/\u53d1\u9001\/\u53cd\u6ce8\u518c\u5e76\u53d1<\/section>\n<\/li>\n<li>\n<section><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">mActions<\/code>\uff1a\u4ee5 Action \u4e3a key\u3001\u6ce8\u518c\u8be5 Action \u7684 BroadcastReceiver \u94fe\u8868\u4e3a value\u3002\u53d1\u9001\u540e\u5feb\u901f\u627e\u5230\u80fd\u63a5\u6536\u7684 Receiver<\/section>\n<\/li>\n<\/ul>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u56db\u3001\u53d1\u9001\uff1amatch \u540e\u4e22\u7ed9 Handler<\/span><\/h2>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public boolean sendBroadcast(Intent intent) {\n    synchronized (mReceivers) {\n        final String action = intent.getAction();\n        final String type = intent.resolveTypeIfNeeded(mAppContext.getContentResolver());\n        final Uri data = intent.getData();\n        final String scheme = intent.getScheme();\n        final Set&lt;String&gt; categories = intent.getCategories();\n        \u2026\u2026\n        ArrayList&lt;ReceiverRecord&gt; entries = mActions.get(intent.getAction());\n        if (entries != null) {\n            if (debug) Log.v(TAG, &quot;Action list: &quot; + entries);\n\n            ArrayList&lt;ReceiverRecord&gt; receivers = null;\n            for (int i=0; i&lt;entries.size(); i++) {\n                ReceiverRecord receiver = entries.get(i);\n                if (receiver.broadcasting) {\n                    if (debug) {\n                        Log.v(TAG, &quot;  Filter&#x27;s target already added&quot;);\n                    }\n                    continue;\n                }\n\n                int match = receiver.filter.match(action, type, scheme, data,\n                        categories, &quot;LocalBroadcastManager&quot;);\n                if (match &gt;= 0) {\n                    if (debug) Log.v(TAG, &quot;  Filter matched!  match=0x&quot; +\n                            Integer.toHexString(match));\n                    if (receivers == null) {\n                        receivers = new ArrayList&lt;ReceiverRecord&gt;();\n                    }\n                    receivers.add(receiver);\n                    receiver.broadcasting = true;\n                } else {\n                    \u2026\u2026\n                }\n            }\n\n            if (receivers != null) {\n                for (int i=0; i&lt;receivers.size(); i++) {\n                    receivers.get(i).broadcasting = false;\n                }\n                mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));\n                if (!mHandler.hasMessages(MSG_EXEC_PENDING_BROADCASTS)) {\n                    mHandler.sendEmptyMessage(MSG_EXEC_PENDING_BROADCASTS);\n                }\n                return true;\n            }\n        }\n    }\n    return false;\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u6309 Action \u4ece mActions \u53d6\u51fa ReceiverRecord\uff0c\u5faa\u73af\u7528 filter.match \u6bd4\u5bf9 action\u3001type\u3001scheme\u3001data\u3001categories\u3002\u5339\u914d\u5219\u653e\u5165 receivers\uff0c\u518d\u53d1 what \u4e3a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">MSG_EXEC_PENDING_BROADCASTS<\/code> \u7684\u6d88\u606f\u7ed9 Handler\u3002match \u89c4\u5219\u89c1 Intent Filter \u4ecb\u7ecd\u3002<\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e94\u3001executePendingBroadcasts<\/span><\/h2>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">private void executePendingBroadcasts() {\n    while (true) {\n        BroadcastRecord[] brs = null;\n        synchronized (mReceivers) {\n            final int N = mPendingBroadcasts.size();\n            if (N &lt;= 0) {\n                return;\n            }\n            brs = new BroadcastRecord[N];\n            mPendingBroadcasts.toArray(brs);\n            mPendingBroadcasts.clear();\n        }\n        for (int i=0; i&lt;brs.length; i++) {\n            BroadcastRecord br = brs[i];\n            for (int j=0; j&lt;br.receivers.size(); j++) {\n                br.receivers.get(j).receiver.onReceive(mAppContext, br.intent);\n            }\n        }\n    }\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u628a mPendingBroadcasts \u8f6c\u6210\u6570\u7ec4\uff0c\u5faa\u73af\u6bcf\u4e2a receiver \u8c03 onReceive\uff0c\u5e7f\u64ad\u6838\u5fc3\u903b\u8f91\u5c31\u7ed3\u675f\u4e86\u3002<\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u516d\u3001\u53d6\u6d88\u6ce8\u518c<\/span><\/h2>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">public void unregisterReceiver(BroadcastReceiver receiver) {\n    synchronized (mReceivers) {\n        ArrayList&lt;IntentFilter&gt; filters = mReceivers.remove(receiver);\n        if (filters == null) {\n            return;\n        }\n        for (int i=0; i&lt;filters.size(); i++) {\n            IntentFilter filter = filters.get(i);\n            for (int j=0; j&lt;filter.countActions(); j++) {\n                String action = filter.getAction(j);\n                ArrayList&lt;ReceiverRecord&gt; receivers = mActions.get(action);\n                if (receivers != null) {\n                    for (int k=0; k&lt;receivers.size(); k++) {\n                        if (receivers.get(k).receiver == receiver) {\n                            receivers.remove(k);\n                            k--;\n                        }\n                    }\n                    if (receivers.size() &lt;= 0) {\n                        mActions.remove(action);\n                    }\n                }\n            }\n        }\n    }\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4ece mReceivers \u548c mActions \u91cc\u5220\u6389\u5bf9\u5e94\u9879\u3002<\/p>\n<hr>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u4e03\u3001\u7ed3\u8bba<\/span><\/h2>\n<table style=\"border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; text-align: left; overflow: auto; display: table; overflow-wrap: break-word; word-break: break-all;\" width=\"817\">\n<thead>\n<tr>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u5bf9\u6bd4<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u7cfb\u7edf BroadcastReceiver<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">LocalBroadcastManager<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u901a\u4fe1<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">Binder \u8de8\u8fdb\u7a0b<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u8fdb\u7a0b\u5185 Handler<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u8303\u56f4<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u53ef\u8de8\u5e94\u7528<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u4ec5\u5e94\u7528\u5185<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5b89\u5168 \/ \u6548\u7387<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u9700\u6743\u9650\u3001\u5f00\u9500\u5927<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u66f4\u5b89\u5168\u3001\u66f4\u5feb<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5339\u914d<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u7cfb\u7edf IntentFilter<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u540c\u6837\u7528 IntentFilter.match<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u6838\u5fc3\u5b9e\u73b0\u5176\u5b9e\u662f Handler\uff0c\u53ea\u662f\u501f\u7528\u4e86 IntentFilter \u7684 match\uff1bBroadcastReceiver \u6362\u6210\u522b\u7684\u63a5\u53e3\u4e5f\u884c\uff0c\u53ea\u662f\u6cbf\u7528\u73b0\u6210\u6982\u5ff5<\/section>\n<\/li>\n<li>\n<section>\u56e0\u4e3a\u662f Handler \u505a\u7684\u5e94\u7528\u5185\u901a\u4fe1\uff0c\u81ea\u7136\u66f4\u5b89\u5168\u3001\u6548\u7387\u66f4\u9ad8\u2014\u2014\u4e0d\u662f Binder<\/section>\n<\/li>\n<\/ul>\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\"><strong>\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1aLocalBroadcastManager \u4e0d\u662f Binder\uff0c\u662f\u4e3b\u7ebf\u7a0b Handler + IntentFilter.match \u7684\u5e94\u7528\u5185\u6295\u9012\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>LocalBroadcastManager \u53ea\u80fd\u505a\u5e94\u7528\u5185\u901a\u4fe1\uff0c\u6bd4\u7cfb\u7edf BroadcastReceiver \u66f4\u5b89 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[199],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1221"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1221"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1221\/revisions"}],"predecessor-version":[{"id":1225,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1221\/revisions\/1225"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}