refactoring method of using listener

add setListener method
fix parameter
fix sample app