If you want to listen to an event, then create one.
A simple way to do this is to define an interface that the "listener" object must implement to be notified when the event occurs.
Start with the interface, declaring it in the class Lib:
public interface OnFinishListener{
public void onFinish();
}
If you want to pass some information to the "listener" state parameters in the interface method(onFinish()
)
Declare a method to specify to the class Lib which listener wants to be notified:
//Atributo para guardar o "ouvinte"
private OnFinishListener listener;
public void setOnFinishListener(OnFinishListener listener){
this.listener = listener;
}
Whenever you want the class Lib notify the "listener" use:
if(listener != null){
listener.onFinish();
}
To use do so:
Lib lib = new Lib (getActivity());
lib.setOnFinishListener(new OnFinishListener(){
@Override
public void onFinish(){
//Coloque aqui o código a ser executado quando receber a notificação.
}
});
lib.iniciaInteratividade();
Cool, worked right, thanks Ramaral. :D
– Marcelo López
If this is what you were looking for consider accepting the answer by clicking on the V in the upper left corner of it.
– ramaral
Had clicked on but not on v , done, thanks again.
– Marcelo López