Skip to content

Instantly share code, notes, and snippets.

@blessedbyjobs
Created April 23, 2020 10:16
Show Gist options
  • Save blessedbyjobs/e239cdbd9a711e8893c99f4fea0ead8e to your computer and use it in GitHub Desktop.
Save blessedbyjobs/e239cdbd9a711e8893c99f4fea0ead8e to your computer and use it in GitHub Desktop.
Весь код, необходимый для запуска какой либо работы в отдельном потоке (через Thread) и возвращение результата в главный поток
val handler = object : Handler() {
fun handleMessage(jObject: JSONObject) {
Log.i("Example", "Success: $jObject")
}
}
val runnable = Runnable {
val result = "{\"someKey\":\"someValue\"}"
val jObject = JSONObject(result)
handler.handleMessage(jObject)
}
val thread = Thread(runnable)
thread.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment