M
M
mihsaklimov2019-01-03 23:56:35
Java
mihsaklimov, 2019-01-03 23:56:35

Changing interface from another thread?

The interface is a button and a textView. When the button is pressed, a new thread is created in which a socket is created and receives and transmits data.
How do I pass this string as text to this textView? Throws an exception that I can only use the interface on the thread it was created on.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2019-01-04
@mihsaklimov

runOnUiThread in activity.
Still smoking Handler.
Back in 2019, it’s not customary in Android to create a thread like this. Use JobManager or Foreground Service with separate thread pool.
You can also take Rx, just in case.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question