Featured post
android - AsyncTask onPostExecute never gets called -
i not sure doing wrong onpostexecute never gets called.
- created base class called baseactivity.java
- from original activity extended class.
- placed posttoopenfeint class inside baseactivity
called ui thread main activity doing:
new posttoopenfeint.execute();
the onpreexecute(), doinbackground(..) gets triggered, reason onpostexecute never gets called.
thank in advance!
dave
private class posttoopenfeint extends asynctask<void, void, void> { /* * (non-javadoc) * * @see android.os.asynctask#doinbackground(params[]) */ @override protected void doinbackground(void... params) { // work here return null; } /* * (non-javadoc) * * @see android.os.asynctask#onpostexecute(java.lang.object) */ @override protected void onpostexecute(void result) { // todo auto-generated method stub super.onpostexecute(result); toast.maketext(mainscreen.this, "done syncing", toast.length_long).show(); } /* * (non-javadoc) * * @see android.os.asynctask#onpreexecute() */ @override protected void onpreexecute() { // todo auto-generated method stub super.onpreexecute(); toast.maketext(mainscreen.this, "about sync scores", toast.length_long).show(); }
looking more, able observe. example if place call:
new posttoopenfeint.execute();
right after oncreate of activity, works fine. if place call inside button listener.
settingsbutton.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { new posttoopenfeint.execute(); } });
the onpostexecute() never gets called, not sure doing wrong. restriction read call ui thread , calling ui thread.
i had similiar problem now. extending asynctask<integer,integer,integer>
, onpostexecute method looked like:
protected void onpostexecute(int result)
this seemed ok me, again i'm more of .net guy java guy. changed to:
protected void onpostexecute(integer result)
because reason java thinks there difference between int
, integer
?
i think problem you're declaring return type void
in your:
extends<void,void,void>
that means no params, no progress , no result. if want execute when it's done, think need give kind of value , integer or boolean.
if change extends to:
<void,void,integer>
now passing no params, not publishing progress, returning value. change onpostexecute
method accept integer
:
protected void onpostexecute(integer result)
then change return in doinbackground
method like:
return 1;
then should execute you.
- Get link
- X
- Other Apps
Comments
Post a Comment