Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
When i call asyncktaskclass.execute("") method , just after this line i want to get result back from the post execute method of asynck task class , here the code snippet

Java
public void method()
{
String val;
new BackgroundTask.execute("");
//// here i want result back from this Back Ground task class immediately without making main thread sleep/////

Log.v("value coming from asyncktask class",val);
/////the problem is this val value is comming null,because log.v line executes before than post execute methd ....////



plz help me to resolve this issue....

thanks
Posted
Updated 13-Jan-14 21:55pm
v2

First of all I added some format to your question. Now it's readable.

You should check the Reference: AsyncTask Reference[^] @ developer.android.com/reference

and take a look at the great tutorials of Lars Vogel for this:
Android Background Processing with Handlers and AsyncTask and Loaders - Tutorial[^] @ Vogella.com
 
Share this answer
 
v2
Hello,

Create one class that extends AsyncTask like,
public class QuestionHelper extends AsyncTask<String, String, ArrayList<HashMap<String, String>>>

public QuestionHelper(Context ctx)
	{
		this.ctx = ctx;
	}

and then in other class or activity, go like this
ArrayList<HashMap<String, String>> QuestionsList = new QuestionHelper(getApplicationContext()).execute().get();;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900