0

I can see emitted messages from the server in the Android app's console log using System.out. How do I actually use this new data to change things in my UI though?

I have tried setText on a TextView that I got a handle to in onCreate. No error is thrown but nothing actually happens.

I also tried making a Toast but I get an error java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare().

theblang
  • 10,215
  • 9
  • 69
  • 120

1 Answers1

1

That error is saying that you are trying to change the UI(Toast) from a different thread.. if you want to change the UI from a different thread you must call the UI/Main thread first and put it there..

Sample::

runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            //Do the changing of UI here
                        }
                 });
Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63