Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Localbroadcastmanager
Cấu phần phần mềm này và các lớp trong đó không còn được dùng nữa. Thay vào đó, hãy dùng LiveData hoặc luồng phản ứng.
Bản cập nhật mới nhất |
Bản phát hành ổn định |
Bản phát hành dùng thử |
Bản phát hành beta |
Bản phát hành alpha |
Ngày 12 tháng 1 năm 2022 |
1.1.0 |
- |
- |
- |
Ý kiến phản hồi
Ý kiến phản hồi của bạn có thể giúp chúng tôi cải thiện Jetpack. Hãy cho chúng tôi biết nếu bạn phát hiện lỗi mới hoặc có ý tưởng cải thiện thư viện này. Vui lòng xem các lỗi hiện có trong thư viện này trước khi báo một lỗi mới. Bạn có thể thêm lượt bình chọn cho lỗi hiện có bằng cách nhấp vào nút dấu sao.
Báo lỗi mới
Xem tài liệu về Công cụ theo dõi lỗi để biết thêm thông tin.
Phiên bản 1.1.0
Phiên bản 1.1.0
Ngày 12 tháng 1 năm 2022
Phát hành androidx.localbroadcastmanager:localbroadcastmanager:1.1.0
. Phiên bản 1.1.0 bao gồm các thay đổi sau.
Những thay đổi quan trọng kể từ phiên bản 1.0.0
Hoàn toàn không dùng androidx.localbroadcastmanager
nữa. Thư viện này sẽ không còn bản phát hành nào khác. Nhà phát triển nên thay thế việc sử dụng LocalBroadcastManager
bằng việc triển khai các kiểu mẫu ghi nhận được khác. Tuỳ theo trường hợp sử dụng, có một số phương án phù hợp như LiveData
hoặc luồng phản ứng.
Phiên bản 1.1.0-rc01
Ngày 15 tháng 12 năm 2021
Phát hành androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-rc01
. Phiên bản 1.1.0-rc01 bao gồm các thay đổi sau.
Phiên bản 1.1.0-alpha01
Ngày 17 tháng 12 năm 2018
androidx.localbroadcastmanager
không được dùng nữa trong phiên bản 1.1.0-alpha01
.
Lý do
LocalBroadcastManager
là một tuyến nghe sự kiện (event bus) toàn ứng dụng và bao gồm mọi vi phạm về lớp (layer violation) trong ứng dụng của bạn; thành phần nào cũng có thể nghe sự kiện của một thành phần khác.
- Cấu phần này kế thừa các giới hạn trường hợp sử dụng không cần thiết của hệ thống
BroadcastManager
; nhà phát triển bắt buộc phải sử dụng Intent
mặc dù các đối tượng chỉ tồn tại trong một quy trình và không bao giờ rời khỏi đó. Cũng vì lý do này mà cấu phần này không tuân thủ BroadcastManager
toàn tính năng .
Việc này có thể khiến nhà phát triển thấy khó hiểu.
Thay thế
- Bạn có thể thay thế việc sử dụng
LocalBroadcastManager
bằng các cách triển khai khác cho các kiểu mẫu ghi nhận được. Tuỳ theo trường hợp sử dụng, có một số phương án phù hợp như LiveData
hoặc luồng phản ứng.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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."]]