透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Localbroadcastmanager
這個構件和其類別已淘汰。請改用 LiveData 或回應式串流。
最新版 |
穩定版 |
候選版 |
Beta 版 |
Alpha 版 |
2022 年 1 月 12 日 |
1.1.0 |
- |
- |
- |
意見回饋
您的意見可協助我們改善 Jetpack。如果您發現新問題,或是有改進這個程式庫的建議,請告訴我們。回報新問題前,請先查看這個程式庫的現有問題。只要按一下星號按鈕,即可投票給現有的問題。
建立新問題
詳情請參閱 Issue Tracker 說明文件。
1.1.0 版本
1.1.0 版本
2022 年 1 月 12 日
發布 androidx.localbroadcastmanager:localbroadcastmanager:1.1.0
。1.1.0 版包含此連結所列的修訂項目。
自 1.0.0 版以來的重要異動
完全淘汰了 androidx.localbroadcastmanager
。這個程式庫不會再發佈新版本。開發人員應將 LocalBroadcastManager
相關應用改為透過其他方式實作可觀測的模式。視用途而定,適合的選項可能是 LiveData
或回應式串流。
1.1.0-rc01 版本
2021 年 12 月 15 日
發布 androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-rc01
。1.1.0-rc01 版本包含這些修訂版本。
1.1.0-alpha01 版本
2018 年 12 月 17 日
1.1.0-alpha01
版本將淘汰 androidx.localbroadcastmanager
。
原因
LocalBroadcastManager
是整個應用程式的事件匯流排,囊括應用程式中的資料層違規事項;所有元件都能監聽任何其他元件的事件。
- 其從
BroadcastManager
系統沿用了不必要的用途限制;即使物件僅存在於一個程序中且絕對不會離開該程序,開發人員仍必須使用 Intent
。正因如此,這個類別在功能面與 BroadcastManager
有出入。
最終產生的體驗容易讓開發人員感到混淆。
取代選項
- 您可以將
LocalBroadcastManager
相關應用改為透過其他方式實作可觀測的模式。視用途而定,適合的選項可能是 LiveData
或回應式串流。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Localbroadcastmanager\n=====================\n\n[User Guide](/guide/components/broadcasts) [Code Sample](https://github.com/android/location-samples/blob/master/LocationUpdatesForegroundService/app/src/main/java/com/google/android/gms/location/sample/locationupdatesforegroundservice/MainActivity.java) \nAPI Reference \n[androidx.localbroadcastmanager.content](/reference/kotlin/androidx/localbroadcastmanager/content/package-summary) \nThis artifact and its classes are deprecated. Use LiveData or reactive streams instead. \n\n| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |\n|------------------|-----------------------------------------------------------------|-------------------|--------------|---------------|\n| January 12, 2022 | [1.1.0](/jetpack/androidx/releases/localbroadcastmanager#1.1.0) | - | - | - |\n\nFeedback\n--------\n\nYour feedback helps make Jetpack better. Let us know if you discover new issues or have\nideas for improving this library. Please take a look at the\n[existing issues](https://issuetracker.google.com/issues?q=componentid:460939%20status:open)\nin this library before you create a new one. You can add your vote to an existing issue by\nclicking the star button.\n\n[Create a new issue](https://issuetracker.google.com/issues/new?component=460939&template=1422575)\n\nSee the [Issue Tracker documentation](https://developers.google.com/issue-tracker)\nfor more information.\n\nVersion 1.1.0\n-------------\n\n### Version 1.1.0\n\nJanuary 12, 2022\n\n`androidx.localbroadcastmanager:localbroadcastmanager:1.1.0` is released. [Version 1.1.0 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/abade69a222024e74015882531553477622890a5..d2d922e60b4cb018c91276a85fb27a05b8a2b0c9/localbroadcastmanager/localbroadcastmanager)\n\n**Important changes since 1.0.0**\n\n`androidx.localbroadcastmanager` has been fully deprecated. There will be no further releases of this library. Developers should replace usages of `LocalBroadcastManager` with other implementations of the observable pattern. Depending on the use case, suitable options may be `LiveData` or reactive streams.\n\n### Version 1.1.0-rc01\n\nDecember 15, 2021\n\n`androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-rc01` is released. [Version 1.1.0-rc01 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/86267e31251cdaf875674004b9937ff3da0c3f24..abade69a222024e74015882531553477622890a5/localbroadcastmanager/localbroadcastmanager)\n\n### Version 1.1.0-alpha01\n\nDecember 17, 2018\n\n`androidx.localbroadcastmanager` is being deprecated in version `1.1.0-alpha01`.\n\n**Reason**\n\n- `LocalBroadcastManager` is an application-wide event bus and embraces layer violations in your app; any component may listen to events from any other component.\n- It inherits unnecessary use-case limitations of system `BroadcastManager`; developers have to use `Intent` even though objects live in only one process and never leave it. For this same reason, it doesn't follow feature-wise `BroadcastManager` .\n\nThese add up to a confusing developer experience.\n\n**Replacement**\n\n- You can replace usage of `LocalBroadcastManager` with other implementations of the observable pattern. Depending on your use case, suitable options may be `LiveData` or reactive streams."]]