Based on a button click, I have to do some processing that requires some time. So I decided to do this in a separate thread from the main UI thread.
Now, based on the calculations in the separate thread, I call a function in the main class of UI thread from which this new thread was created. In this function, I update the UI. I was told that this won't work as I need to call the main UI thread.
Could someone please help me with this?
@Override
public void onListItemClicked(int index, Map<String, Object> data) {
new Thread(new Runnable() {
@Override
public void run() {
// Issue command() on a separate thread
wasCommandSuccess(command());
}
}).start();
}
private void wasCommandSuccess(boolean result){
if (result == false){
getUI(BasicUI.class).showAlert("Command failed!", "Unable to access");
}
}