0
 public class GetAllEggs extends AsyncTask<Void, Void, List<Egg>>  {
    List<Egg> eggs;
    Egg eg;
     JSONParser jParser = new JSONParser();
    @Override
    protected void onPreExecute() {
        super.onPreExecute();

    }
    @Override
    protected List<Egg> doInBackground(Void... params) {
        // TODO Auto-generated method stub

        try {
            // Thread.sleep(5000);
            /*** fetch data from server and save in the local db ***/
            String url = Utils.alleggsofuser;
            JSONObject jObject  = jParser.makeHttpRequest(url, "GET", null);
            //Log.d(DEBUG_TAG, "news response: " + response);


            JSONArray categoryArray = new JSONArray(
                    jObject.getString("categories"));






            for (int i = 0; i < categoryArray.length(); i++) {
                /* make entries in the db */
                JSONObject Category = categoryArray.getJSONObject(i);
                eg=new Egg();
                    eg.setEggid(Category.getInt("eggid"));

                    eg.setApp_user_id(Category.getInt("app_user_id"));

                    eg.setEgg_query(Category.getString("egg_query"));
                    eg.setEgg_date_time(null);
                    eggs.add(eg);
                /**/
            }

            /**/
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            // pBar.cancel();
        }
        return eggs;
    }

    protected void onPostExecute(List<Egg> result) {
        // TODO Auto-generated method stub


    }


List<Egg> eggs=new ArrayList();  
new GetAllEggs().execute(eggs);

i want eggs to grab data returned by GetAllEggs().execute().

So that i can Use the eggs returned, in another class where it can be displayed.

I am trying to assign the data returned to a list in the new class.

I cannot carry out the operation in postexecute() because of the structure of the program

NetStarter
  • 3,189
  • 7
  • 37
  • 48

1 Answers1

0

Instead of passing from post execute to ui thread i can call a ui thread in post execute using runOnUiThread(new Runnable() { public void run() {}});