Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8563451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:57:47+00:00 2026-06-11T16:57:47+00:00

I’m implementing an asyncTask class to load the data from server. I have the

  • 0

I’m implementing an asyncTask class to load the data from server.
I have the data already and I want to pass it to the UI Thread, but I don’t know how.

This is the code:

public class InboxHandler extends FragmentActivity implements OnLineSelectedListener {

    static final int GET_CODE = 0;
    private TextView textView3, textView2;
    private Button button1, button2, button3;
    private LinearLayout tab1, tab2, tab3;
    private CheckBox cbVerPorCategoria;
    private ActionBar actionBar;
    private TextView txtTitle;
    private Settings settings;
    FragmentTransaction fragmentTransaction;
    BottomPanel bottomPanel;
    public List<OrderRequest> orderRequestArray;
    private OrderRequestParser orderRequestParser;
    public static int number;
    int clickCounter = 0;
    private boolean doubleBackToExitPressedOnce = false;
    private static Context context;
    DataLoader dataLoader;
    private MyAsynckTask myAsynckTask;

    public InboxHandler(){}

    public List<OrderRequest> getOrderRequestArray() {
        return orderRequestArray;
    }

    public void setOrderRequestArray(List<OrderRequest> orderRequestArray) {
        this.orderRequestArray = orderRequestArray;
    }

    public static Context getContext()
    {
        return context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_inbox);

        context = this.getApplicationContext();

        settings = Settings.getInstance();
        settings.setPrefs(getSharedPreferences(settings.getPREFERENCES(), Activity.MODE_PRIVATE));
        settings.setPrefsEditor(settings.getPrefs().edit());        
        settings.getPrefsEditor().putBoolean("isLoggedIn", true);
        settings.isVistaSimple = true;

        actionBar = (ActionBar) findViewById(R.id.actionbar);

        initComponents();
        prepareActionBar();
    }

    private void initComponents() {

        try {
            MyAsynckTask myAsynckTask = new MyAsynckTask(this); 
            myAsynckTask.execute(); 

            //HERE I USED A SUGGESTION IN A SIMILAR QUESTION. THAT IS: PASS THE ACTIVITY TO THE ASYNCTASK, AND FROM IT, SAVE IN THE ACTIVITY, THE DATA THAT IU WANT FROM THE ASYNCTASK. I DO THAT, BUT IN THE ACTIVITY, THE DATA IS NULL I SUPPOSE DUE TO, I DONT EVEN SEE IN THE LOGCAT,  THE FOLLOWING RESULT:

            try{
                Log.e("e", ""+this.getOrderRequestArray().get(0).getDocNumber());
            } catch(Exception e){
                e.printStackTrace();
            }

//If you see the onPostExecute, I test if the data I want is there. and it is there! I set that to the list of the class InboxHandler, but in the above code, when i try to test if it is there, it´s not. And that code don´t even appear in logcat. The "Log.e("e", ""+this.getOrderRequestArray().get(0).getDocNumber());" nor the "e.printStackTrace();"

            bottomPanel =new BottomPanel();
            Bundle bundle = new Bundle();
            bundle.putSerializable("arrayPedidos", (Serializable) orderRequestArray);
            bottomPanel.setArguments(bundle);

            //actionBar.setTitle("Inbox");
            NotificationFragment notificationFragment = new NotificationFragment(orderRequestArray, actionBar);

            Bundle bundleNotificationFragment = new Bundle();
            bundleNotificationFragment.putString("title", "Inbox");
            notificationFragment.setArguments(bundleNotificationFragment);

            fragmentTransaction = getSupportFragmentManager().beginTransaction();
            fragmentTransaction.add(R.id.frame_list_container, notificationFragment);
            fragmentTransaction.add(R.id.frame_bottom_panel, bottomPanel);      
            fragmentTransaction.commit();

        } 
        catch(Exception e)
        {
            e.printStackTrace();
        }

    }

    private class MyAsynckTask extends AsyncTask {

        private String stringMensaje;
        public List<OrderRequest> orderRequestArray;
        private OrderRequestParser orderRequestParser;
        private Request request;
        private Settings settings;
        private InboxHandler inboxHandler;

        public MyAsynckTask(InboxHandler inboxHandler){
            this.inboxHandler = inboxHandler;
        }

        @Override
        protected Object doInBackground(Object... params) {

            List<OrderRequest> array = this.getOrderRequests();
            settings = Settings.getInstance();


            if(array != null){
                settings.setOrderRequestArray(array); 
                orderRequestArray = array;
                Log.e("orderRequestArray", "Me trajo el orderRequestArray en doInBackground!");
            } else {
                Log.e("orderRequestArray", "No me trajo el orderRequestArray en doInBackground!");
            }

            return array;

        }

        @Override
        protected void onPostExecute(Object result) {
            super.onPostExecute(result);

            List<OrderRequest> array = (List<OrderRequest>) result;

            this.setOrderRequestArray(array);

            if(orderRequestArray != null){
                inboxHandler.setOrderRequestArray(orderRequestArray);
                Log.e("orderRequestArray", "is not null en onPostExecute!");
            } else {
                Log.e("orderRequestArray", "is null en onPostExecute!");
            }


            if(inboxHandler.getOrderRequestArray() != null){
                Log.e("inboxHandler.getOrderRequestArray()", "is not null en onPostExecute!");
            }
            else {
                Log.e("orderRequestArray", "is null en onPostExecute!");
            }
        }


        public List<OrderRequest> getOrderRequests() {

            orderRequestParser = new OrderRequestParser();
            orderRequestArray = new ArrayList<OrderRequest>();
            List<OrderRequest> orderRequestArray = orderRequestParser.listOrderRequest();

            Settings.getInstance().setOrderRequestArray(orderRequestArray);
            if(orderRequestArray != null){
                Log.e("orderRequestArray", "Me trajo el orderRequestArray en getOrderRequestArray!");
            } else {
                Log.e("orderRequestArray", "No me trajo el orderRequestArray en getOrderRequestArray!");
            }

            return orderRequestArray;

        }

        public void setOrderRequestArray(List<OrderRequest> orderRequestArray) {
            this.orderRequestArray = orderRequestArray;
        }

        public List<OrderRequest> getOrderRequestArray() {
            return orderRequestArray;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:57:48+00:00Added an answer on June 11, 2026 at 4:57 pm
    protected void onPostExecute(Object result)
    

    it is running in GUI thread, you can access GUI elements there.

    and only there should be the:

            try{
                Log.e("e", ""+this.getOrderRequestArray().get(0).getDocNumber());
            } catch(Exception e){
                e.printStackTrace();
            }
    

    and

        Bundle bundle = new Bundle();
        bundle.putSerializable("arrayPedidos", (Serializable) orderRequestArray);
        bottomPanel.setArguments(bundle);
    

    I can’t see any reason, why is this question down voted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.