Created
November 14, 2017 18:50
-
-
Save MacoChave/7d9630ef1439f18c7269ab99db7ddd29 to your computer and use it in GitHub Desktop.
Event Bus. Comunicación entre Activity's y Fragment's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* CREAR VARIABLE EventBus */ | |
private EventBus bus = EventBus.getDefault(); | |
/* ENVIAR OBJETO */ | |
bus.post(new ObjetoEnviar()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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