• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to build a loading please wait from a activity that not async

HeavensSentSword

Well-Known Member
So this is a tuff one. I have a activity that calls a class that call a http downloader which is the async task. What I want to do is have a please wait loading screen notification for the user while the activity is getting all the data from the web. I don't have a clue on how to get the loading screen to be called. Usually you would have it in the async task but my async task does not have a view. How to best go about doing this?
Thank you for any help.
My http client does have a doInBackground() so should I put the on preExecute and postExecute there? But then how would my main method which is twice removed know when its down and when its not.
 
Ok so I have been working on this and still nothing. What is happening is that when a button is clicked it starts the activity and starts to process all the methods, but it linger on the first activity until everything is done loading. I don't want that I want the progress dialog. It just won't show. Any thoughts on this?

Java:
 Tracker customerPageTracker;

    ProgressDialog progress;

    String myName;
    int myTotal;
    int myAvaliable;
    String myRank;
    String customerNumber;
    Bitmap barcode = null;

    String customrURl;

    ImageView imageview;
    TextView num ,pointText, pointsEarned,rank,customerName,myPurchases;
    Button logout, account, more;

    //Variables to send to the server for customers
    String customer_id;
    String android_id;
    String notification_id;
    String operating_system_type;

    Tracker mTracker;
    AnalyticsApplication app;
    Activity myActivity;
    Context customerPageContext;

    CustomerInfoJsonParser cijp;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mypage_layout);
        //build statusbar
        CustomStatusbar customStatusbar = new CustomStatusbar();
        customStatusbar.makeSatusBar(this);
        progress = ProgressDialog.show(this, "Loading", "PleaseWait", true);
        cijp  = new CustomerInfoJsonParser();

        customrURl = getString(R.string.customerCRM);

        customerPageContext = this;
        //generate the UI
        getUIAssignments();

        // [START shared_tracker]
        // Obtain the shared Tracker instance.
        app = (AnalyticsApplication) getApplication();
        mTracker = app.getDefaultTracker();
        // [END shared_tracker]
        mTracker.setScreenName("CustomerPage Screen");
        mTracker.send(new HitBuilders.ScreenViewBuilder().build());

        customerPageTracker = ((AnalyticsApplication) getApplication()).getDefaultTracker();
        myActivity = this;

        asignValues(cijp, myPurchases);

        new Thread(new Runnable() {
            @Override
            public void run()
            {
                // do the thing that takes a long time
                //fill in the customers information
                buildBarcode(imageview, num);

                runOnUiThread(new Runnable() {
                    @Override
                    public void run()
                    {
                        createUI(pointText, pointsEarned, rank, customerName);
                        getSendingData();

                        progress.dismiss();
                    }
                });
            }
        }).start();



        //Build the rules for the buttons
        myButtons(customerPageTracker);
        ButtonControler bc = new ButtonControler();
        bc.buttonPressed(this);


    }
 
Ok so I updated this significantly now I am using a local class that is a async. I feel that this is a step in the right direction, but still does not work.

It now displays the dialog but never goes away. I feel that it has an issues with not knowing that it is done processing so it just keeps running. Now this is calling a json parser which is calling a http downloader. If that makes any difference.
Here is what I am doing now
Java:
 private class runningMan extends AsyncTask<Void, Void, Void>
    {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();

            Log.d("Runningman: ", "Started running");
            //this method will be running on UI thread
            progress = ProgressDialog.show(customerPageContext, "Loading", "PleaseWait", true);
            progress.show();
        }

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

            Log.d("Runningman: " , "Is still running");
            asignValues(cijp, myPurchases);
            buildBarcode(imageview, num);


            return null;
        }
        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);

            Log.d("Runningman: " , "Finished runing");
            //this method will be running on UI thread
            createUI(pointText, pointsEarned, rank, customerName);
            getSendingData();

            progress.dismiss();
        }


    }

}
 
Yeah that may be the issue. I was thinking that my self seeing that if the onPost doesnt know when the doInBackground is done. It maybe a little deeper than that but I feel that this is the main issue with what is going on
 
Back
Top Bottom