Example of Java AsyncTask
private class doSomethingInAnotherThread extends AsyncTask<Void, Void, Void>
{
@Override
protected Void doInBackground( Void... params )
{
// Do the work here
EventBus.getDefault().post(new CustomEvent(custom_data));
return null;
}
@Override
protected void onPostExecute( Void result )
{
// Executed on main thread
}
}
// in onCreate
EventBus.getDefault().register(this);
// in activity class somewhere
@SuppressWarnings( "UnusedDeclaration" )
public void onEventMainThread( CustomEvent event )
{
}