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

  • SEARCH
  • Home
  • 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 7442301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:09:14+00:00 2026-05-29T11:09:14+00:00

I´m using the compatibility library v4+. Following other threads and the dev guide I´m

  • 0

I´m using the compatibility library v4+.
Following other threads and the dev guide I´m trying to create a fragment that calls a progress dialog from the activity that creates it.
The approach uses DialogFragment displayed in the pre execute of an AsyncTask and dismissed (removed) on the post execute.
As result I don´t get the any dialog…. well, the truth is that the dialog gets displayed only for a fraction of second at the end of the thread.sleep.

Can someone tell me where I´m wrong?

I have my fragment here:

public class GroupsDetailsFragment extends BaseFragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
       // Inflate the layout for this fragment
       View v = inflater.inflate(R.layout.fragment_groups_details, container, false);

       return v;
    }



    @Override
    public void onStart() {
        // TODO Auto-generated method stub
        super.onStart();
        loadPage();
    }



    public void loadPage() {
        Log.i(TAG, "loadPage");
        new LoadPageTask(getBaseActivity()).execute();
    }

    public void executeLoadPagePreExecution() {Log.i(TAG, "executeLoadPagePreExecution"); }
    public void executeLoadPageInBackground() {Log.i(TAG, "executeLoadPageInBackground"); }
    public void executeLoadPagePostExecution() {try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }Log.i(TAG, "executeRefreshPostExecution"); }



    protected class LoadPageTask extends AsyncTask<Void, Void, String> {
        private Context context;

        public LoadPageTask(Context context) {
            super();
            this.context = context;
        }

        @Override
        protected void onPreExecute() {
            // before the network request begins, show a progress indicator
            getBaseActivity().showLoadingProgressDialog(context);
            executeLoadPagePreExecution();
        }

        @Override
        protected String doInBackground(Void... params) {
            String result = executeLoadPage();
            Log.i(TAG, "error message result: " + result);
            return result;
        }


        // Returns null if Everything is OK. Error Message if any problem.
        private String executeLoadPage() {
            try {
                executeLoadPageInBackground();
                return null;
            } catch (Exception e){
                Log.w(TAG, e.getMessage(), e);
                return(e.getMessage());
            }
        }

        @Override
        protected void onPostExecute(String message) {
            executeLoadPagePostExecution();
            getBaseActivity().dismissProgressDialog();
            if (message!=null){
                Utility.showMessageAlertDialog(message, context);
            }
        }
    }

}

And ProgressDialogFragment which is inner class of the FragmentActivity that dispays the fragment:

public static class ProgressDialogFragment extends DialogFragment {


        public static ProgressDialogFragment newInstance(String title, String message) {
            ProgressDialogFragment fragment = new ProgressDialogFragment();
            Bundle args = new Bundle();
            args.putString("title", title);
            args.putString("message", message);
            fragment.setArguments(args);

            return fragment;
        }

        @Override
        public ProgressDialog onCreateDialog(Bundle savedInstanceState) {
            String title = getArguments().getString("title");
            String message = getArguments().getString("message");

            ProgressDialog progressDialog = new ProgressDialog(getActivity());
            progressDialog.setTitle(title);
            progressDialog.setMessage(message);

            progressDialog.show();

            return progressDialog;
        }
    }


    public void showProgressDialog(String title, String message) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

        Fragment prev = fragmentManager.findFragmentByTag("progress dialog");
        if(prev!=null) {
            fragmentTransaction.remove(prev);
        }
        fragmentTransaction.addToBackStack(null);

        DialogFragment newFragment = ProgressDialogFragment.newInstance(title, message);
        newFragment.show(fragmentManager, "progress dialog");
        //fragmentTransaction.commit();
    }

    public void removeProgressDialog() {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

        Fragment prev = fragmentManager.findFragmentByTag("progress dialog");
        if(prev!=null) {
            fragmentTransaction.remove(prev);
        }
        fragmentTransaction.commit();
    }
  • 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-05-29T11:09:15+00:00Added an answer on May 29, 2026 at 11:09 am

    Usually you should not pause the UI thread. So how about moving the Thread.Sleep() into doInBackground()? Does this work for you?

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

Sidebar

Related Questions

Hello I'm writing an application that uses the compatibility library and i'm using a
I'm currently using a CursorLoader inside a Fragment with the Android Compatibility Library. Almost
How to get rid of this, I am using the Google compatibility library for
First things first, I'm using the compatibility library and here's the error I'm getting:
I'm aware of the setListShown(false) and setListShown(true) issue when using the Compatibility Library with
I have a fragment class that extends Fragment and calls setHasOptionsMenu to participate in
I am using android compatibility library, and I am having some problems with listfragments
I'm using the Android Compatibility library to implement fragments and have extended the layout
This only happens when using the compatibility library for pre-3.0 devices I'm getting an
I'm converting an app to use fragments using the compatibility library. Now currently I

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.