If you need it to perform asynchronous operations, look at AsyncTask - this is the class in which you implement doInBackground, where your long operation is performed, and the onPostExecute method, where the code that is supposed to update the interface is executed.
Now, if you want to pass some special code to your AsyncTask, which will be executed after a long operation, you can:
(1) , /, :
interface MyInterface {
void doWork();
};
class MyAsyncTask extends AsyncTask<Void,Void,Void> {
MyInterface oper;
public MyAsyncTask(MyInterface op) { oper = op; }
public onPostExecute(Void res) {
oper.doWork();
}
}
class MyActivity extends Activity implements MyInterface {
public void doWork() {
}
public void startWork() {
new MyAsyncTask(this).execute();
new MyAsyncTask(new MyInterface() {
public void doWork() {
}
});
}
};
(2) , EventBus, .
(3) , :
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
}
});