interface - implementing listener for background activity android -
i using data droid library speed asynchronous tasks. in data droid there method similar onpostexecute
of async task.i performing async task using data droid pre fetching of data. want implement listener notifying background process completion activity.can explain how achieve interface.i have gone through many stackoverflow questions still unclear how implement interface this.
public abstract class baseactivity extends activity implements completionlistener { completionlistener completionlistener; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); completionlistener=this; } class mytask extends asynctask<void, void, void>{ @override protected void doinbackground(void... params) { // todo auto-generated method stub return null; } @override protected void onpostexecute(void result) { super.onpostexecute(result); completionlistener.oncompletion(); } } }
let activity extend baseactivity , mytask asynchronous task activity extending base class receive call onpostexecute();
public interface completionlistener { public void oncompletion(); }
Comments
Post a Comment