Created
April 23, 2020 10:16
-
-
Save blessedbyjobs/e239cdbd9a711e8893c99f4fea0ead8e to your computer and use it in GitHub Desktop.
Весь код, необходимый для запуска какой либо работы в отдельном потоке (через Thread) и возвращение результата в главный поток
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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