java - Intent onPostExecute() AsyncTask -


im running asynctask in inner class , once complete within onpostexecute() want use intent pass values activity have 2 errors im not sure how fix.

the errors occur on setresult() line @ result_ok , finish() line explaining these 2 actions cannot occur outside of activity. how use intent in onpostexecute of 'asynctask'?

code:

protected void onpostexecute(void result)  {     // todo auto-generated method stub     super.onpostexecute(result);     intent intent = new intent();     intent.putextra("jobs", jobstatus);     intent.putextra("requestssent", requests);     setresult(result_ok, intent);     finish(); } 

you need use context of activity class following finish method:

youractivity.this.finish() 

and result_ok exists on activity class, need:

activity.result_ok 

so code must following:

intent intent = new intent(); intent.putextra("jobs", jobstatus); intent.putextra("requestssent", requests); setresult( activity.result_ok, intent); youractivity.this.finish() 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -