I've been searching this online for a long time. Maybe what I'm doing here is wrong.
I have written a thread class in a separate file from MainActivity.java. Because both the thread and the main activity are relatively long, I decided to separate them into different files.
I wanted to pass some value generated from the thread class to the main activity. Initially I want to use handlers. But because the thread is in a different class to the main activity. It has no idea the handler I defined in the main activity.
public class mythread implements Runnable{
@Override
public void run(){
result = result_from_some_task();
}
}
This is the basic structure of my thread class and I want to pass result back to the main activity. I've looked at many examples, most of them the thread is within the main activity class and the handlers defined can be easily referred to.
Intent doesn't seems to be applicable. Does anyone have any idea on how such operations can be done?
Thanks in advance.