Search code examples
android-jetpack-composebroadcastreceiver

Broadcast receiver change UI


I have searched widely but not found an answer to this question: Is it possible to change a variable in a Jetpack compose user interface from a broadcast receiver?


Solution

  • You can't modify your compose ui from Broadcast receiver directly. Instead, your Broadcast receiver should change some data in your data layer - datastore, preferences, database or just in memory in some Repository singleton class. Then you should make this data observable and observe them from your compose ui.