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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:18:57+00:00 2026-06-10T18:18:57+00:00

In my app, I need to get a value from an AlertDialog which displays

  • 0

In my app, I need to get a value from an AlertDialog which displays a list. After an item is selected, I change the button text (the button which displays the AlertDialog), the dialog is dismissed, and i need to do treatment in onResume().

But onResume is not called and i get the warning “Window already focused”. I think the cause is that i change the button text from the dialog so i’m already in the window. But i need to go in onResume(à . how to do that ?

AlertDialog :

AlertDialog.Builder mBuilder = new AlertDialog.Builder(this);
    mBuilder.setTitle("Type de l'observation");
    mBuilder.setSingleChoiceItems(titles,-1, new DialogInterface.OnClickListener(){
        public void onClick(DialogInterface dialogInterface, int item) {
            mDescriptor.setmObservationValue(
                    mContext.getResources().getStringArray(R.array.post_values)[item]);
            mObservationButton.setText(titles[item]);
            dialogInterface.dismiss();
            return;
        }
    });
    mDialog = mBuilder.create();

The onClick method :
public void onObservationClick(View v) {
mDialog.show();
}

and onResume() :

    @Override
protected void onResume() {
    if(!mDescriptor.getmObservationValue().equals(""))
    {
        String value = mDescriptor.getFieldKey();
        Log.v("VALUE : ",value);
        if(value.equals("VentValue"))
        {
            mFieldLayout.setVisibility(View.VISIBLE);
            mUnit.setText("km/h");
        }
        else if(value.equals("PluieValue"))
        {
            mFieldLayout.setVisibility(View.VISIBLE);
            mUnit.setText("mm");
        }   
        else if(value.equals("NeigeValue"))
        {
            mFieldLayout.setVisibility(View.VISIBLE);
            mUnit.setText("mm");
        }
        else if(value.equals("TempValue"))
        {
            mFieldLayout.setVisibility(View.VISIBLE);
            mUnit.setText("°C");
        }
        else if(value.equals("VisValue"))
        {
            mFieldLayout.setVisibility(View.VISIBLE);
            mUnit.setText("m");
        }
        else
        {
            mFieldLayout.setVisibility(View.GONE);
            mUnit.setText("");
        }
    }
  • 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-10T18:18:58+00:00Added an answer on June 10, 2026 at 6:18 pm

    It looks like you are forcibly calling onResume(), but you cannot do this. The Activity is not paused to display an AlertDialog, therefor onResume() is not called after the Dialog is dismissed. Simply move the code that you have in onResume() into another method and call this method when the Dialog is closed.

    Consider using an OnDismissListener

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

Sidebar

Related Questions

Hi i'm making an app which need to get user's gmail account contact list
I have QListWidget in my app, I need to get string value of item
In my app i'm using TBXML parser where i need to get a value
I have an app where I need to get the list of countries,languages etc
I need to get the value returned from a stored procedure in my Sql
I need to get a value from my cursor. The value needs to be
What's the best way to get a value from NSUserDefaults on app load and
In my Android app, I need to get 50,000 database entries (text) and compare
In my app I need to get mirrored and rotated copies of video files
I have an app that I need to get the source code to update

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.