'jetpack compose not updating icon
the title is updated on changes but the icon ist not.
@Composable
fun topBar(title: String) {
val context = LocalContext.current
var showMenu by remember { mutableStateOf(false) }
val health = remember { Health() }
val healthMin = remember { mutableStateOf(R.drawable.music) }
TopAppBar(title = {
val location = remember { mutableStateOf("") }
SystemBroadcastReceiver(MediaPlaybackService.LOCATION_CHANGE) { intent ->
location.value = intent!!.getStringExtra(MediaPlaybackService.LOCATION_CHANGE)!!
}
Text(text = location.value)
},
navigationIcon = {
SystemBroadcastReceiver(Health.STATUS) { intent ->
health.onReceive(null, intent)
healthMin.value = health.updateLogo()
}
IconButton(onClick = {}) {
Log.i("TEST","Value = ${healthMin.value}")
Icon(
painter = painterResource(healthMin.value),
"contentDescription"
)
}
},
...
I can see the changes in the log. But the UI is not updated
2022-02-24 12:56:24.117 3032-3032/com.example.myapplication I/TEST: Value = 2131231223
2022-02-24 12:56:24.525 3032-3032/com.example.myapplication I/TEST: Value = 2131231226
The SystemBroadcastReceiver is taken from the case-study official documentaion
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
