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 7028995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:28:47+00:00 2026-05-28T00:28:47+00:00

When my app gets launched i am calling a Asyn Task function. In the

  • 0

When my app gets launched i am calling a Asyn Task function. In the background process its hitting 3 APIs and their parsing functions goes on, It will be taking around 10 minutes of time.

In that case if the user clicks on the android default back button, then the asyn task used to get cancelled. To avoid this i tried blocking the back button action as follows.

class First_Time_Sync extends AsyncTask<Void, Void, Void> 
     {
        ProgressDialog dialog1 = new ProgressDialog(Progressss.this);

        protected void onPreExecute() 
        {   
            backMode = true;
            dialog1.setMessage("Welcome \nThank you for waiting.");
            dialog1.setIndeterminate(true);
            dialog1.show();
        }       

        protected Void doInBackground(Void... arg0) 
        {
            .................                   
            return null;
        }

        protected void onPostExecute(Void unused) 
        {
            backMode = false;
            dialog1.dismiss();
        }
     }

 @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) 
    {
        if (keyCode == KeyEvent.KEYCODE_BACK) 
        {
            if (backMode) 
            {
                return true;
            }
            else 
            {
                return super.onKeyDown(keyCode, event);
            }
        }       
        return super.onKeyDown(keyCode, event);
    }

Now when the async task function called and if the user clicks back button progress bar gets cancelled. But the background process goes on and the back button is been blocked until the background process completes.

I want the progress bar to be shown even if the back button is pressed, so that it may not get vanished.

How to do this……

  • 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-28T00:28:48+00:00Added an answer on May 28, 2026 at 12:28 am

    You will have to set the cancelable property of the dialog to false

    dialog1.setCancelable (false);

    This will prevent back key from cancelling your dialog

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

Sidebar

Related Questions

in my app, when the activity gets launched i am calling an AsynTask to
My app gets crashed when its in the process of registering.I have tried many
in my app when an activity is launched i am hitting an url and
I'm building a full-screen iPhone optimized web app. It gets launched from the homepage
Is there an easy way to detect when a .NET app gets or loses
We have a NET app that gets installed to the Program Files folder. The
I have a Django app that gets it's data completely from an external source
I have made an app that gets an array of addresses from a web
I am making an application (iPhone app) which gets information (jokes) from an RSS
I've got a very small standalone vb.net app that gets run automatically. Every now

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.