I have created an java class in android studio and I want to use runOnUiThread() in this class. Can I run runOnUiThread() thread without Activity.xml in Android? If Answer is yes? than how?
Asked
Active
Viewed 4,868 times
1 Answers
13
Yes. You just need to use Handler
.
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
}
});

Zeon
- 535
- 8
- 23
-
with this code snippet i can update UI? – nisarg parekh Jul 20 '18 at 10:31
-
1@nisarg yes, you can – Zeon Jul 20 '18 at 10:34
-
1Also instead of calling `new Runnable() { }`, You can use a lambda: `() -> { }` – SomeMosa Sep 19 '20 at 15:00