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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:48:32+00:00 2026-06-07T16:48:32+00:00

There is an activity which is fired by intents: sets, shows and hides the

  • 0

There is an activity which is fired by intents: sets, shows and hides the ProgressDialog. When it sets and shows the activity works fine, but when the hide is called, instead of calling the onDestroy method the onCreate is called. Here is a LogCat when the activity starts:

SHOW_PROGESS
SET_PROGESS
onCreate
onStart
onResume
SET_PROGESS
onPause
DialogSET 15
onResume
SET_PROGESS
onPause
DialogSET 16
onResume
...

The ProgressDialog is set and shown in onNewIntent(Intent intent) method. But when the hide task is called the

pd.dismiss();
finish();

are called and instead of calling onDestroy the onCreate is called:

HIDE_PROGESS
onPause
DialogHIDE
onResume
onPause
onCreate
onStart
onResume
onStop
destroyed
Activity -activityName- has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41347af0 that was originally added here android.view.WindowLeaked

There is a white display without ProgessDialog. After pushing the BACK button the

onPause
onDestroy 

are called and then I can see wat I want. How can I solve that I shouldn’t push the BACK button to call the onDestroy again?

The intent is started this way:

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.setAction(intent.ACTION_VIEW);

                startActivity(intent);

Thank you!

EDIT:

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);                     

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        extras = getIntent().getExtras();

        progress = 0;
        max = extras.getInt("max");
        title = extras.getInt("title");

        pd = new ProgressDialog(this);

        pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        pd.setCancelable(false);

        Log.w("screenPD", "onCreate");
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);

        setIntent(intent);

        int newTitle = intent.getExtras().getInt("title");

        if (intent.getExtras().getString("action").equals("set")){
            pd.setTitle(newTitle);
            pd.setMessage(intent.getExtras().getString("message"));
            max = intent.getExtras().getInt("max");
            pd.setMax(max);
            pd.setProgress(intent.getExtras().getInt("progress"));
            pd.show();

            Log.e("DialogSET", "DialogSET "+intent.getExtras().getInt("progress"));
        }
        else if (intent.getExtras().getString("action").equals("show")){
            pd.setProgress(intent.getExtras().getInt("progress"));
            pd.setMessage(intent.getExtras().getString("message"));
            //pd.show();

            Log.e("DialogSHOW", "DialogSHOW "+progress);

        }
        else if (intent.getExtras().getString("action").equals("hide")){

            //pd.dismiss();
            finish();

            Log.e("DialogHIDE", "DialogHIDE");

        }
    }
  • 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-07T16:48:34+00:00Added an answer on June 7, 2026 at 4:48 pm

    This is what is said on the documentation for onNewIntent():

    An activity will always be paused before receiving a new intent, so you can count on onResume() being called after this method.

    I believe the problem you are seeing is due to the finish() call being made in onNewIntent() and then the framework (seeing that it needs to resume your activity as the next step) revives your Activity again.

    Try moving your code in onNewIntent() to onResume() instead (maybe adding a flag too to check whether processing is needed), something like:

    private boolean mNewIntentProcessed;
    
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
    
        setIntent(intent);
    
        mNewIntentProcessed = false;
    
        // move the rest of the code here to onResume() ..
    }
    
    
    @Override
    protected void onResume() {
        super.onResume();
    
        if (!mNewIntentProcessed) {
    
            final int newTitle = intent.getExtras().getInt("title");
    
            // the rest of your code from onNewIntent() should be moved here ..  
    
            mNewIntentProcessed = true;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some problem with Android AsyncTask. There is an Activity which contains some
here i am using an activity in which there is a list view,which I
Is there any difference between AsyncSync being fired up from Activity or IntentService? I'm
I had window leak in my application activity which i fixed. But, when i
I am creating an android application in which there are two activites. One activity
I have an activity which handles configuration changes. But now i have to change
In my activity there is a toggle button. I want every time you change
Alright, so i have an Activity. In the activity there is a textview and
In an android Activity is there a way to programmatically list the it has
Is there a way to vizualise the activity stack, at some moment during debug,

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.