Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- Compose
- Coroutine
- ProGuard
- android
- 코드포스
- livedata
- Hilt
- Coroutines
- TEST
- 프로그래머스
- textfield
- 코루틴
- relay
- activity
- 암호학
- 백준
- androidStudio
- MiTweet
- GitHub
- AWS
- 쿠링
- pandas
- Python
- Codeforces
- architecture
- Gradle
- Rxjava
- MyVoca
- boj
- Kotlin
Archives
- Today
- Total
이동식 저장소
[Android] Cannot invoke setValue on a background thread 본문
원인
메인 스레드 이외의 스레드에서는 MutableLiveData의 value를 할당할 수 없다.
해결 방법
postValue() 메소드를 사용하면 된다. 참 쉽죠?
fun loadData = viewModelScope.launch(Dispatchers.IO) {
...
mutableLiveData.postValue(newValue)
...
}'Primary > Android' 카테고리의 다른 글
| [Hilt] 2. Dependency Injection with Hilt (5) | 2021.04.29 |
|---|---|
| [Hilt] 1. 의존성 주입이란? (1) | 2021.04.29 |
| [Android] Transformations.map이 동작하지 않을 때 (0) | 2021.02.17 |
| [Android Kotlin Fundamentals] Lifecycle (2) | 2021.02.03 |
| [Android Kotlin Fundamentals] Navigation path (0) | 2021.02.02 |
Comments