0
I am trying to import an Android library into a Java desktop project. But the library doesn’t find any classes that are related to import android.os
.
I’m having trouble with class Handler android.os.Handler
.
Some substitution for that:
public void run() {
Looper.prepare();
handler = new Handler();
Looper.loop();
}
Ok. From what I’ve researched here, I’ve also come to that conclusion. Thank you. ?
– sebastiaorealino
I haven’t worked with android for some time, but if I’m not mistaken, Looper allows an android thread to receive messages, and Handler is precisely the reference that allows the connection of the current thread with the other. Any callback passed to the thread should fix this. (I may be wrong, as I said earlier, I no longer remember the android api)
– Ricardo Rodrigues de Faria
I found something equivalent in that answer. http://stackoverflow.com/questions/18628751/how-to-instantiate-handler-in-java#new-Answer Swingutilities.invokeLater(r); substui o Handler.post(r) Thanks Ricardo. I’m new around here and I can’t give you a score yet.
– sebastiaorealino
Don’t worry man, we’re here to help.
– Ricardo Rodrigues de Faria