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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:22:31+00:00 2026-06-17T01:22:31+00:00

I use activity A to start background download using AsyncTask , when download finished,

  • 0

I use activity A to start background download using AsyncTask, when download finished, AsyncTask.postExecute will popup a AlertDialog. However, during download, I switch to another Activity B or any other activities. The result is that the AlertDialog can’t show out. AlertDialog uses activity context(Here should be A). So, how can I show out the AlertDialog?

AlertDialog.Builder builder = new  AlertDialog.Builder(context);
builder.setMessage(context.getString(R.string.install));
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
{
    @Override
    public void onClick(DialogInterface dialog, int which)
    {
        //onSure();
    }
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener()
{
    @Override
    public void onClick(DialogInterface dialog, int which)
    {
        //onCancle();
    }
});

builder.create().show();
  • 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-17T01:22:33+00:00Added an answer on June 17, 2026 at 1:22 am

    If it is a long running task that can’t complete before Activity A completes then I would suggest using an IntentService. But it depends on what you need. Doing this will allow it to finish in the background and not hold up the UI. There are probably other options but this sounds like the best from what I know of your situation. Other than that, you can wait to start the next activity and start it with a button in the dialog once the AsyncTask finishes, if that is an option

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

Sidebar

Related Questions

Normally, if I want to start a new activity I can use StartActivity(typeof(foo)); This
In my Activity I use multiple AsyncTask classes. How to cancel AsyncTask when Activity
I have a backgorund thread that extends AsyncTask and which I use in activity
I write a program support download file. When in this download activity, I start
I want to track new activity start , I use this code to only
I have an error when i use intent to start activity when i choose
In my app I have a background task (using AsyncTask) that downloads stuff from
I want to start a service once my activity is put in the background
I want to use an activity as dialog and i made the theme of
Is there any command i can use in activity class that disables TextViews that

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.