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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:51:11+00:00 2026-06-06T03:51:11+00:00

Say we have two activities, Activity1 and Activity2. In Activity1’s onClick() method, we have

  • 0

Say we have two activities, Activity1 and Activity2.

In Activity1’s onClick() method, we have a call to start Activity 2 if a certain button is pressed:

Intent myIntent = new Intent(Activity1.this, Activity2.class);
Activity1.this.startActivity(myIntent);

After finish() is called in Activity2, and Activity1 is resumed, I need a dialog to show in Activity1, as soon as it is resumed.

Before, I simply called showDialog(id) in the same block of Activity1’s onClick() method:

public void onClick(View v) {
     if(v == addHole){
     //...
     Intent myIntent = new Intent(Activity1.this, Activity2.class);
     Activity1.this.startActivity(myIntent);
     showDialog(END_DIALOG_ID);
     }
}

The issue is, after Activity1 resumes, the dialog corresponding to END_DIALOG_ID is not visible, but the screen is darkened and unresponsive (as if the dialog were present), until the back key is pressed.

I have tried putting the showDialog() call in Activity1’s onResume() and onRestart() methods, but these both crash the program.

I have also tried creating an AsyncTask method in Activity2, with the showDialog() call in its onPostExecute(), but the dialog is not visible in Activity2.

private class ShowDialogTask extends AsyncTask<Void, Void, Integer> {
    /** The system calls this to perform work in a worker thread and
     * delivers it the parameters given to AsyncTask.execute() */
    protected Integer doInBackground(Void... id) {
        //do nothing
        return END_DIALOG_ID;
    }

    /** The system calls this to perform work in the UI thread and delivers
     * the result from doInBackground() */
    protected void onPostExecute(Integer id) {
        super.onPostExecute(id);
        showDialog(id);

    }
}

I am now trying to implement this by calling

Activity1.this.startActivityForResult(myIntent, END_DIALOG_REQUEST);

with corresponding setResult() and onActivityResult() methods from Activity1, but it seems that there should be a better practice for implementing this. All I need is to have a dialog shown upon Activity2 finishing.

Thanks for any help you can provide.

  • 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-06T03:51:12+00:00Added an answer on June 6, 2026 at 3:51 am

    Like you suggest, call startActivityForResult when starting Activity2. Then, override onActivityResult and check for RESULT_OK, and show your dialog box then. That’s a perfectly acceptable practice for doing what you’re looking to do.

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

Sidebar

Related Questions

I have two activities, say Activity A and Activity B . Activity A is
I have created two activities say A and B. Activity A lists list of
Say I have two Activities in an Android application, EditPerson and EditEmployee . It
I have two activities. Home activity contain a list view with two buttons named
I have two packages say com.android.package1 and com.android.package2 An activity in package1 (say A)
Say I have two buttons Add Link and Add Text. The Add Link button
Say I have two overloaded versions of a C# method: void Method( TypeA a
I have two Activities, say A1 and A2. sequence being A1->A2 From A1 I
I have two activities, say LoginActivity which contains a login UI and HomeActivity .
Say I have two Java apps that I wrote: Ping.jar and Pong.jar and they

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.