Skip to content

Instantly share code, notes, and snippets.

@MacoChave
Created November 14, 2017 18:50
Show Gist options
  • Save MacoChave/7d9630ef1439f18c7269ab99db7ddd29 to your computer and use it in GitHub Desktop.
Save MacoChave/7d9630ef1439f18c7269ab99db7ddd29 to your computer and use it in GitHub Desktop.
Event Bus. Comunicación entre Activity's y Fragment's
/* CREAR VARIABLE EventBus */
private EventBus bus = EventBus.getDefault();
/* ENVIAR OBJETO */
bus.post(new ObjetoEnviar());
/* CREAR VARIABLE EventBus */
private EventBus bus = EventBus.getDefault();
/* IMPLEMENTAR METODOS */
public void onPause()
{
super.onPause();
bus.unregister(this);
}
public void onResume()
{
super.onResume();
bus.register(this);
}
/* CREAR METODO CAPTURADOR SUBSCRITO A org.greenrobot.eventbus */
@Subscribe
pubic void ejecutarLlamada(ObjetoEnviar objeto)
{
string = "Se recibió " + objeto.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment