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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:29:31+00:00 2026-06-04T09:29:31+00:00

I am using AsyncTask to download files. There i implemented progress: //Updating progress dialog

  • 0

I am using AsyncTask to download files. There i implemented progress:

//Updating progress dialog
protected void onProgressUpdate(Integer... changed) {
    progressDialog.setProgress(changed[0]);
}

//STARTED 
@Override
protected void onPreExecute() {

    try {
        progressDialog = new ProgressDialog(context);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setMessage(context
                .getString(R.string.message_loading));
        progressDialog.setCancelable(false);
        progressDialog.show();
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}

Everything is working fine in portrait and landscape. For notification that file was downloaded i am using interface.

So wrong is when i start downloading my file in portrait or landscape and while it not done i rotate device then progress disappear and callback fire exception as there is no where to go.

When i rotate device my Activity is re created, so how to do this properly. I need to restrict that when downloading is started user couldn’t rotate device, then how to do that.

Or there are solutions to 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-06-04T09:29:32+00:00Added an answer on June 4, 2026 at 9:29 am

    If you want to restrict orientation while downloading then just before starting downloads use this code. this will restrict users device orientation.

    int current_orientation = getResources().getConfiguration().orientation;
    if (current_orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    

    This code you can use after finishing orientation which allow user to rotate device again.

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    

    hope it will help you.

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

Sidebar

Related Questions

I'm using AsyncTask to update a horizontal Progress Dialog. There are no errors. The
I am using this code (inside an AsyncTask) to download files: URL u =
i'm using AsyncTask to retrive data from RSS ,,i'm showing a progress Dialog in
I am using asyncTask to show Dialog and then after few minutes then launch
I'm using AsyncTask to download an image and want to send the downloaded image
I'm using AsyncTask in my custom Dialog. AsyncTask works fine in activity, but inside
I have the following code that downloads a video using AsyncTask. //DOWNLOAD VIDEOS private
I'm using AsyncTask to download and parse XML content from i-net. Downloading and parsing
This is related to my previous post Problem with downloading multiple files using AsyncTask
I'm using an AsyncTask to download Images for my Listview, because I dont want

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.