티스토리 뷰
build.gradle (Module: app)
dependencies {
// Coroutine
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
}
MainActivity.kt
package com.jwsoft.kotlinproject
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
GlobalScope.launch(Dispatchers.IO) {
launch {
throw Exception()
}
}
}
}
앱이 강제로 종료됨.
MainActivity.kt
package com.jwsoft.kotlinproject
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val handler = CoroutineExceptionHandler {coroutineContext, throwable ->
Log.e("", throwable.toString())
}
GlobalScope.launch(Dispatchers.IO + handler) {
launch {
throw Exception()
}
}
}
}
'Android > Kotlin' 카테고리의 다른 글
[Kotlin] import org.json.* (0) | 2020.07.31 |
---|---|
[Kotlin] MVVM + Coroutine (0) | 2020.07.30 |
[Kotlin] Coroutine + ViewModel (0) | 2020.07.29 |
[Kotlin] Coroutine (2) (0) | 2020.07.29 |
[Kotlin] Thread.join() (0) | 2020.07.27 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Architecture Pattern
- Intent
- 안드로이드 #코틀린 #Android #Kotlin
- TabLayout
- 코틀린
- JSONArray
- CoordinatorLayout
- fragment
- James Kim
- java
- 안드로이드
- activity
- JSONObject
- Design Pattern
- Livedata
- ViewPager2
- ViewModel
- 자바
- Android
- View
- Vue.js #Vue.js + javascript
- XML
- DataBinding
- 혀가 길지 않은 개발자
- handler
- Kotlin
- coroutine
- ArrayList
- MVVM
- recyclerview
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함